harirammanohar at gmail.com wrote: >> tree.write('output.xml') >> yup its working well if i include register namespace, else i am getting > ns:0 in every line of output.xml. >> But its removing top line > <?xml version="1.0" encoding="ISO-8859-1"?> The write() method allows you to specify an encoding and/or require an xml declaration: https://docs.python.org/dev/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write