DOM Level 3 XPath

There's another popular way of looking at the data in an XML documentthe Document Object Model (DOM). If you've done any programming that extracted data from XML documents, you're probably familiar with the DOM, because the DOM specifies a set of programming objects and functions that lets you work with the data in an XML document (the DOM objects are implemented in programming languages like JavaScript and Java). You can find more information on the DOM at

Like the XPath data model, the DOM lets you consider an XML document as a tree of nodes, although these nodes are not exactly the same as in XPath. Here are the node types in the DOM:

  • Element

  • Attribute

  • Text

  • CDATA section

  • Entity reference

  • Entity

  • Processing instruction

  • Comment

  • Document

  • Document type

  • Document fragment

  • Notation

Each of these node types corresponds to a programming object with its own methods that let you navigate from node to node or recover the text in a node.

In an attempt to reconcile the data model in the DOM with XPath 1.0, W3C created a version of XPath called "Document Object Model XPath," and you can find it at The idea was to support the creation of XPath functions that would work with standard DOM objectsin other words, to let you work with a DOM tree of nodes using XPath functions. To do that, the DOM version of XPath connects DOM and XPath nodes by first treating XPath nodes in terms of infosets .

The DOM XPath specification is now in Candidate Recommendation status, and you can read all about it at It's never really become very popular, however, because most people consider it just an interim way of relating the XPath and DOM models.

In fact, as you can see, the situation with XPath 1.0, XML infosets, and the DOM data models is a problem because each of these data models is different. W3C has worked on bringing things together in XPath 2.0, however, with the XPath 2.0 data model (more properly called the W3C XQuery 1.0 and XPath 2.0 Data Model). The XPath 2.0 data model forms the basis of data models for a number of XML- related specificationXPath and others, such as XSLT and XQuery. In this way, W3C is doing what it should have done from the beginningcreating one standard data model that will let you treat the data in an XML document as a tree of nodes. More on the XPath 2.0 data model in Chapter 7.

XPath. Navigating XML with XPath 1.0 and 2.0 Kick Start
XPath Kick Start: Navigating XML with XPath 1.0 and 2.0
ISBN: 0672324113
EAN: 2147483647
Year: 2002
Pages: 131

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: