XML technologies / XML / XML in a Nutshell / The Document Object Model (DOM) / Structure of the DOM core
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
DOM Core interfaces provide generic access to all supported document content. DOM also defines HTML-specific interfaces corresponding to parts of HTML documents: tables, paragraphs, and <img> elements. Alongside these, generic interfaces in DOM Core provide access to the same information.
XML was designed for creating application-specific markup languages, so standards committees cannot define application-specific interfaces in advance. DOM instead provides core interfaces for manipulating elements independently of the application.
DOM Core is further divided into basic and extended interfaces. Basic interfaces apply to XML and HTML documents. Extended interfaces handle XML-specific structures such as entity declarations or processing instructions. All DOM Core interfaces derive from a central interface named Node (node). The Node interface provides generic methods for accessing a document or fragment’s tree structure and content.
Generic and application-specific DOM interfaces compared
To simplify document processing and efficient DOM implementation in programming languages, DOM Core offers two ways to access a document tree: through the generic interface Node and through type-specific interfaces. XML constructs such as elements, attributes, and processing instructions can all be related through a hierarchical tree. Elements connect to ancestors, descendants, parents, and children. Despite the variety of node types the same parent, child, and sibling relationships apply throughout XML.
The generic interface Node contains the minimum attributes and methods needed to express a tree. Each Node contains links to locate its parent, children, and siblings. The next page describes the interface Node in detail.
Besides the generic interface Node DOM defines XML-specific interfaces for elements, attributes, processing instructions, and other constructs. All derive from the generic interface Node, letting applications choose their access method by casting between the generic interface Node and the represented object type. The page Specialized node types covers these interfaces and their relationship to the generic Node interface.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de