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.

... sorry, got it wrong...

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.

If you have one file and if it's so critical, why don't simply use an editor?

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

echo "<documentbody>$(cat infile.txt)</documentbody>" > outfile.txt

Or with awk...

 
awk 'BEGIN{print "<documentbody>"}{print $0}END{print "</documentbody>"}' infile

I would also recommend placing the text inside a CDATA section to guard against illegal XML characters.

Thanks for ur help blitzer..

Its working fine.

but i need to add "<?xml version="1.0" encoding="UTF-8"?>" line before documentbody tag.

Can you help me in this also.

Thanks and Regards
Hemant

echo '<?xml version="1.0" encoding="UTF-8"?>' > outfile.txt && echo "<documentbody>$(cat infile.txt)</documentbody>" >> outfile.txt