📜  et.dump 导出文件到 xml 写入方法 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.484000             🧑  作者: Mango

代码示例1
import xml.etree.ElementTree as ET

tree = ET.ElementTree("tree")

document = ET.Element("outer")
node1 = ET.SubElement(document, "inner")
node1.text = "text"

tree._setroot(document)
tree.write("./output.xml", encoding = "UTF-8", xml_declaration = True)