How do I get Python’s ElementTree to pretty print to an XML file?
Whatever your XML string is, you can write it to the file of your choice by opening a file for writing and writing the string to the file. from xml.dom import minidom xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml(indent=” “) with open(“New_Database.xml”, “w”) as f: f.write(xmlstr) There is one possible complication, especially in Python 2, which is both less … Read more