use xml.etree.elementtree to write out nicely formatted xml files,"print(etree.tostring(root, pretty_print=True))"