when using Python\'s stock XML tools such as xml.dom.minidom for XML writing, a file would always start off like
xml.dom.minidom
<
The header is print in Document. If you print the node directly, it won't print the header.
Document
root = doc.childNodes[0] root.toprettyxml(encoding="utf-8")