Home arrow XML arrow Page 4 - XPointer Basics

Proof Of The Pudding - XML

You already know how to link XML documents together with XLink, and isolate specific nodes or node collections with XPath. Now uncover the third and final piece of the XML linking jigsaw - XPointer, an experimental technology from the W3C, which allows you to create XML links to specific points or ranges within an XML document.

  1. XPointer Basics
  2. The Need For XPointer
  3. Revolving Around An Axis
  4. Proof Of The Pudding
  5. A Fragmented View
  6. A Range Of Options
  7. Asymmetrically Yours
  8. Linking Up
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 2
December 12, 2001

print this article


By combining the axis and node test into a location step, and combining multiple location steps into a location path, it becomes possible to locate specific nodes with the document tree quite easily. Using the following XML sample, let's consider some examples.

<?xml version="1.0"?> <movie id="67" genre="sci-fi"> <title>X-Men</title> <cast>Hugh Jackman, Patrick Stewart and Ian McKellen</cast> <director>Bryan Singer</director> <year>2000</year> <?play_trailer?> </movie>
The path

references the text node

Hugh Jackman, Patrick Stewart and Ian McKellen
In order to make this a little easier to read (and write), XPath assumes a default axis of "child" if none is specified - which means that I could also write the above path as

The * character matches all child elements of the context node, while the @ prefix indicates that attributes, rather than elements, are to be matched. The path

would match all the children of the "movie" element, while the path

would refer to all the attributes of the movie element. In case I need a specific attribute - say, "genre", I could use the path

or the path

both of which would reference the value

Finally, the path

would reference the first element under the document root, which also happens to be the outermost element, while the path


selects all the elements in the document.

So far as constructing basic XPointers go, the material above is more than sufficient for your needs. However, if you'd like to learn more about XPath's capabilities, including its built-in functions and expressions, take a look at the XPath tutorial  at the XPath specification at http://www.w3.org/TR/xpath.html.

>>> More XML Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates


Dev Shed Tutorial Topics: