Processing XML with Perl | Michel Rodriguez |
XSL and CSS | SAX |
The Document Object Model (DOM)
The DOM is both an object model of an XML (and HTML) document and an API to access and manipulate the document.
The DOM is widely used, from browsers to data bases. There are DOM implementations in various languages, notably Java.
The Model:
- All the objects in the DOM inherit from three main classes: Node, NodeList, and NamedNodeMap.
- Any component of a document inherits from the Node class.
- A NodeList is an array of Nodes. The method that returns the children of an element returns a NodeList.
- A NamedNodeMap is a hash of nodes. The attributes of an element for example can be obtained in a NamedNodeMap.
- A Document node is an entire document, an Element node represents an element, an Attr node represents an attribute of an element, and a Text node represents a string.
- There are Node types for all types of components, including comments, processing instructions... XML::DOM even adds Node types for element and attribute declarations in the DTD.
- Of course all Node types inherit the methods of the Node class.
XSL and CSS | SAX |