Walk the DOM tree
Use the ElementTree module in the standard library to read an XML
document. See people.xml for a sample XML document.
- Parse the document to get a document object.
- Get the root node from the document.
- Walk the DOM tree.
- For each node in the tree, print out (1) the element (tag)
name, (2) the attributes of the node (name and value), and (3)
text content of the node.
What you will learn:
- How to process an XML document with the ElementTree implementation
of the Document Object Model (DOM).
- How to use and manipulate a DOM tree.
- How to use the ElementTree module from the standard Python library.