One common way to identify an element in an XML document is by location. Identifying an element by location is generally accomplished by counting children down from the root. For example, the following XPointer points to John P. Muller's PERSON element:


A tumbler is a shortcut for XPointers exemplified by the second example above; that is, an XPointer that consists of nothing but a series of child relative location steps counting down from the root node, each of which selects a particular child by position only. The shortcut is to use only the position number and the slashes that separate individual elements from each other, like this:


/1/4 is a tumbler that says to select the fourth child element of the first child element of the root. This syntax can be extended for any depth of child elements. For example these two URIs point to John P. Muller's NAME and SPOUSE elements respectively:


Each tumbler always points to a single element. You cannot use tumblers with any other relative location steps. You cannot use them to select elements of a particular type. You cannot use them to select attribute or strings. You can only use them to select a single element by its relative location in the tree.

Previous | Next | Top | Cafe con Leche

Copyright 1999 Elliotte Rusty Harold
Last Modified August 20, 1999