XPath Concepts

In this section, we will review the way in which an XPath processor views an XML document.

XML Documents as Trees

An XML document simply consists of a series of characters. The use of characters to create the logical structure for that document is constrained by the rules of XML 1.0. In XML 1.0 syntax, we might have elements nested within each other, as shown in the following code snippet:

<AnElement> 
 <AnotherElement>
  <!-- Some more content -->
 </AnotherElement>
</AnElement>

The outermost element can also be viewed in the XPath data model as a node from which branches can spread out. The AnElement element is, in the XPath data model, represented by an element node—the AnElement element node. The AnotherElement element node is ...

Get Special Edition Using XML, Second 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.