March 2019
Beginner
490 pages
12h 40m
English
It would be useful for us to be able to produce output in a more legible format, such as the example shown at the beginning of this section. To do this, we can use another XML API, minidom, provided by the standard library.
We can use the following commands to print some nicely formatted XML:
>>> import xml.dom.minidom as minidom>>> print(minidom.parseString(ET.tostring(root)).toprettyxml()) <?xml version="1.0" ?> <root> <book> <name>Book1</name> </book> </root>
Read now
Unlock full access