Kirt wrote:
> i dont wanna parse the xml file..
>
> Just open the file as:
>
> f=open('test.xml','a')
>
> and append a line "<Body2>abc</Body2>" before  tag </Top>

Use a regex to split the contents and insert new stuff, eg

import re
prog = prog = re.compile('^(.*)(</Top>)', re.DOTALL)
m = prog.search(f.read())

then m.group(1) is everything before </Top> and m.group(2) is </Top>.
Put them together with your new tag and write it back to the file

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to