xpath Location paths and axes


An XPath location path is a series of location steps separated by a / character:


A location step contains an axis, a node test, and an optional list of predicates. The axis and the node test are separated by two colon characters ::. The predicates are enclosed in square brackets:


The evaluation of a location path starts with a node set containing the context node given by the context of the expression, or the root node, if the location path starts with a /. At each step, each node N in the original node set is replaced with the set of nodes that

  • can be reached from N following the given axis,
  • matches the node test, and
  • matches all predicates.

The result of a location path expression is the final node set obtained after processing all location steps.