Chapter 19. Document Object Model (DOM)

The Document Object Model (DOM) defines an API for accessing and manipulating XML documents as tree structures. The DOM is defined by a set of W3C Recommendations that describe a programming language-neutral object model used to store hierarchical documents in memory. The most recently completed standard, DOM Level 3, provides models for manipulating XML documents, HTML documents, and CSS stylesheets. This chapter covers only the parts of the DOM that are applicable to processing XML documents.

This chapter is based on the DOM Level 3 Core Recommendation, which was released on April 7, 2004. This version of the recommendation, along with any errata that have been reported, is available on the W3C web site (http://www.w3.org/TR/DOM-Level-3-Core/ ). Level 3 introduces several key features that were lacking from earlier DOM Levels, including:

  • Validation—it is now possible to enforce validity constraints during programmatic manipulation of the DOM tree.

  • Type information—post-validation element and attribute type information is now available through standard DOM interfaces.

  • Support for XML 1.1—allows the developer to select which version of the XML recommendation a given DOM document will conform to.

Get XML in a Nutshell, 3rd Edition 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.