Location Paths
A version of this page is also available for
4/8/2010
A location path is an important kind of expression that selects a set of nodes relative to the context node. The result of evaluating the expression is the node-set containing the nodes selected by the location path. Location paths can recursively contain expressions that are used to filter sets of nodes.
The following topics include the syntax and pieces of location paths:
The following text shows examples of location paths.
To select the para element of the context node, you can use the following location path.
child::para
To select all element children of the context node, use the following.
child::*
And to select all text node children of the context node, use the following.
child::text()
Location paths are composed of one or more location steps, each separated by a "/". Each step in turn selects a set of nodes relative to the context node. The location steps are strung together from left to right. The left-most location step selects a set of nodes relative to the context node, which are then used as the context for the following step, and so on, until all steps have been processed.
For example, the following selects the para element children of the div element children of the context node.
child::div/child::para