How to convert a txt file to xml file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to convert a txt file to xml file
# 1  
Old 08-24-2009
How to convert a txt file to xml file

Hello,

I donot have exact lenght of the file.
But i want entire txt of the file to send it into one node.

for example I have txt file..
asdfghjklmnbvcxzqwertyuiop[]., nswwneikniniwn

so i need the output as

<documentbody>asdfghjklmnbvcxzqwertyuiop[]., nswwneikniniwn</documentbody>

iI have to convert this txt file into xml file using shell script



Thanks and Regards
Hemant

---------- Post updated at 01:43 AM ---------- Previous update was at 12:29 AM ----------

Please help..as I have to complete this work today as this is critical.

Last edited by Hemantgupta84; 08-24-2009 at 03:43 AM..
# 2  
Old 08-24-2009
... sorry, got it wrong...
# 3  
Old 08-24-2009
Thanks for ur reply....

But this hard coded evertime a new file will be there when this script is called.
Also will this perl script work in Unix SAP Netweaver system.
# 4  
Old 08-24-2009
Quote:
Originally Posted by Hemantgupta84

Please help..as I have to complete this work today as this is critical.
If you have one file and if it's so critical, why don't simply use an editor?
# 5  
Old 08-24-2009
Thanks for ur suggestion.
I know how to change .txt file manually or using editor.

But i need automate the system. Everytime a file came to unix box its get converted into xml. And i a min 1000 file can come.

THanks and Regards
Hemant
# 6  
Old 08-24-2009
Code:
echo "<documentbody>$(cat infile.txt)</documentbody>" > outfile.txt

# 7  
Old 08-24-2009
Or with awk...
Code:
 
awk 'BEGIN{print "<documentbody>"}{print $0}END{print "</documentbody>"}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert a txt file to a CSV file

Hi , I have a Txt file which consist of 1000's of SOAP request and response and i want the file to be converted to a csv file like column a should have a soap request and column b should have the soap response . can someone assist me in achieving this please ? Thanks (2 Replies)
Discussion started by: kumarm8
2 Replies

2. UNIX for Advanced & Expert Users

Convert CSV file to nested XML file using UNIX/PERL?

we have a CSV which i need to convert to XML using Perl or Unix shell scripting. I was able to build this XML in oracle database. However, SQL/XML query is running for long time. Hence, I'm considering to write a Perl or shell script to generate this XML file. Basically need to build this XML... (3 Replies)
Discussion started by: laknar
3 Replies

3. UNIX for Dummies Questions & Answers

Cannot convert this .pages file to a .txt file?!?

I'm trying to use the textutil feature in terminal to convert this .pages file to a .txt file. I've succeeded converting other files like .doc or .docx over to a .txt but this one in particular is giving me headache. I changed the permission rights to 755 but I don't think that mattered to begin... (1 Reply)
Discussion started by: syregnar86
1 Replies

4. Shell Programming and Scripting

Replace the .txt file between two strings in XML file

Hi i am having XML file with many number of lines,I need to replace between two strings with .txt file using awk. For ex <PersonInfoShipTo ------------------------------ /> My requirement is to replace the content between <PersonInfoShipTo ------------------------------ /> help me. Thanks... (9 Replies)
Discussion started by: Padmanabhan
9 Replies

5. Shell Programming and Scripting

How to convert a .log file into .txt file under unix??

Hi Friends, I have a .log file generated from a tool(Windows PC) which can be opened using a notepad, but when I tried to view the file in unix (cygwin on my laptop) the file type is showing as binary file, So I am unable to process the file. I need to extract some of the selected text... (3 Replies)
Discussion started by: ks_reddy
3 Replies

6. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

7. UNIX for Dummies Questions & Answers

To convert a txt file to .xls file

i want to convert a comma seprated file into a .xls file the file contains 3 fields seprated by a comma. i want to convert it into a .xls file with 3 columns and 37 rows DPRPT400,01/15/2009-15:03:06,01/15/2009-15:03:08 DPRPT401,01/15/2009-15:03:15,01/15/2009-15:03:32... (11 Replies)
Discussion started by: manit
11 Replies

8. Shell Programming and Scripting

convert a txt file to xls file

How to convert a txt file(tab delimiter) to xls file. Looking forward help. Thanks, Venkatesh. (2 Replies)
Discussion started by: venkatesht
2 Replies

9. Shell Programming and Scripting

Convert XML file into TEXT file using PERL seript

Dear Yogesh..."Convert XML file into TEXT file using PERL seript"... can u help me regarding this issue...plz Thanks Rudro (0 Replies)
Discussion started by: Rudro
0 Replies

10. Shell Programming and Scripting

Plz Help To convert xml file to text file using bourn shell scripts

If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts. My xml file: <root> <header_rec recordtype="00"> <record_id>00</record_id> <country_code>AK></country_code>... (0 Replies)
Discussion started by: ram2s2001
0 Replies
Login or Register to Ask a Question