XPointer Concepts

In this section, we will look at the concepts that XPointer adds to those provided in XPath.

Locations

A location generalizes the idea of a node, which you saw in Chapter 11 when we looked at XPath. A location can be a node (as in XPath), a point, or a range. In a moment, we will examine precisely what a point and a range are.

Point Locations

Consider the following snippet of code:

<paragraph number="1"> 
This is the text in the first paragraph. This paragraph has two sentences.
</paragraph>
<paragraph number="2">
This is also a paragraph. It too has two sentences.
</paragraph>

In the XPath data model, the preceding code would have two paragraph element nodes and two text nodes—each text node being a child node of its parent ...

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.