使用Python创建xml文件:
from xml.dom.minidomimport Document
# Create the minidom document
doc = Document()
# Create the
# Create the main
element
# Create a
elemenet some text
# Give the
# Print our newly created XML to console
print doc.toprettyxml(indent=" ")
# Print our newly created XML to d:\out.xml
with open("d:\out.xml", "w") as f:
f.write(doc.toprettyxml(indent=" ")
输出:
< xml version="1.0" >
This is a test!