Chapter 9. The Document Object Model

The Document Object Model, DOM for short, is an abstract data structure that represents XML documents as trees made up of nodes. Various interfaces in the org.w3c.dom package represent elements, attributes, parsed character data, comments, and processing instructions. All of these are subinterfaces of the common Node interface, which provides basic methods for navigating and pruning the tree.

The root of the tree is a Document object that represents a complete, well-formed document. A parser reads an XML document from a stream and builds a Document object representing that XML document. The client program calls the methods of Document and the other DOM interfaces to navigate the tree and extract information ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.