XML technologies / XML / Python & XML / The Document Object Model

(Excerpt from "Python & XML" by Christopher A. Jones & Fred L. Drake, Jr.)

The Document Object Model (DOM) is an interface giving developers programmatic access to a document’s structure. Perhaps the most common use of DOM is “Dynamic HTML” (DHTML), in which an HTML document in the browser can be modified programmatically using an embedded scripting language. This is usually an ECMAScript variant, such as JavaScript or JScript, because most browsers support it, but other languages can also be used. (In Windows browsers, this can even be Python!) This lets you change a table cell’s background color or dynamically switch fonts after the page has loaded in the browser. DOM defines the interface for which vendors can provide compatible APIs.

DOM is also extremely useful when exposed through a library such as the Python standard library or PyXML. It lets you manipulate an XML document already in memory using Python. The DOM interfaces allow you to modify or extract parts of the document.

  

  

 

 

 

back to top