[XML-SIG] Writing XML files with ElementTree

Kent Tenney ktenney at gmail.com
Tue Mar 20 13:05:09 CET 2007


I don't understand how ET provides an
XML Declaration as the file output by ElenemtTree.write()

write() says

    elif encoding != "utf-8" and encoding != "us-ascii":
        file.write("<?xml version='1.0' encoding='%s'?>\n" % encoding)

How do I get the declaration written if I want 
encoding to be utf-8 ?

Do I need to manually paste it into the top of the 
file produced by ET.write()

I haven't found a lot of documentation on using 
ElementTree to produce XML.


More information about the XML-SIG mailing list