from xml.dom.minidom import getDOMImplementation

dom = getDOMImplementation()
document = dom.createDocument(None, , None)

topElement = document.documentElement
firstElement = document.createElement()
topElement.appendChild(firstElement)
textNode = document.createTextNode()
firstElement.appendChild(textNode)

xmlString = document.toprettyxml( * 4)