tree = etree.fromstring(templateXml).getroottree()
xmlFileOut = '/Users/User1/Desktop/Python/Done.xml'
with open(xmlFileOut, 'w') as f:
    f.write(etree.tostring(tree, pretty_print=True, xml_declaration=True,
        encoding=tree.docinfo.encoding, standalone=tree.docinfo.standalone))
XML Declaration standalone="yes" lxml