The id() function is one of the simplest and most robust means of identifying a element node. It selects the element in the document that has an ID type attribute with a specified value. For example, consider the URI"p12")). If you look back at Listing 17-1, you find this element:

<PERSON ID="p12" FATHER="p2" MOTHER="p1">
  <NAME>Honore Bellau</NAME>

Since ID pointers are so common and so useful, there's also a shortcut for this. If all you want to do is point to a particular element with a particular ID, you can skip all the xpointer(id("")) fru-fru and just use the bare ID after the # like this:

XPointers are evaluated from left to right. The first match found is returned, so the backup is only used if an ID type attribute with the value p12 can't be found.

Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
Last Modified February 1, 2000