from lxml import etree
tree = etree.fromstring(templateXml).getroottree()
xmlFileOut = '/Users/User1/Desktop/Python/Done.xml'
with open(xmlFileOut, 'w') as f:
    pass
XML Declaration standalone="yes" lxml