
Creating an XML document in Python can be accomplished by executing:
from xml.dom import minidom
doc = minidom.Document()
testElem = doc.createElement("test")
testElem.setAttribute('id', '1234')
doc.appendChild(testElem)
print doc.toxml()
TheĀ example above creates an XML document, creates a child element, sets an attribute and then appends the child element to the document.
The XML document in the above example looks like:
<?xml version="1.0" ?><test id="1234"/>
