1import xml.etree.cElementTree as ET
2
3root = ET.Element("root")
4doc = ET.SubElement(root, "doc")
5
6ET.SubElement(doc, "field1", name="blah").text = "some value1"
7ET.SubElement(doc, "field2", name="asdfasd").text = "some vlaue2"
8
9tree = ET.ElementTree(root)
10tree.write("filename.xml")
11