xml.dom
The xml.dom module defines some objects and exceptions that are used by parsers that implement the Document Object Model. With DOM, documents are parsed into a tree structure representing the document structure. The tree structure can then be traversed and manipulated as necessary.
As an example of the tree structure, consider the following XML document:
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE recipe [ <!-- The RECIPE DTD appears here --> <!ELEMENT recipe (title, description?, ingredients, directions)> <!ELEMENT ingredients (item+)> <!ELEMENT title (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT item (#PCDATA)> <!ELEMENT directions (#PCDATA)> <!ATTLIST item num CDATA #REQUIRED units (C | tsp | tbl | bottles | none ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.