Después de leer un archivo existente con el XML "feo" y hacer algunas modificaciones, la impresión bonita no funciona. Lo intenté etree.write(FILE_NAME, pretty_print=True)
.Impresora XML bonita de Python con lxml
tengo el siguiente código XML:
<testsuites tests="14" failures="0" disabled="0" errors="0" time="0.306" name="AllTests">
<testsuite name="AIR" tests="14" failures="0" disabled="0" errors="0" time="0.306">
....
y lo uso como esto:
tree = etree.parse('original.xml')
root = tree.getroot()
...
# modifications
...
with open(FILE_NAME, "w") as f:
tree.write(f, pretty_print=True)
¿Qué es e.tree? –