How to write an XML file without header in Python?

后端 未结 7 1287
盖世英雄少女心
盖世英雄少女心 2021-02-06 01:28

when using Python\'s stock XML tools such as xml.dom.minidom for XML writing, a file would always start off like

<

7条回答
  •  长情又很酷
    2021-02-06 02:05

    The header is print in Document. If you print the node directly, it won't print the header.

    root = doc.childNodes[0]
    root.toprettyxml(encoding="utf-8")
    

提交回复
热议问题