O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required