Constructing an XPath with Axis, Node Test, and Predicate

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XPath Developer's Guide

Constructing an XPath with Axis, Node Test, and Predicate

An individual location step in an XPath location path consists of up to three components: an axis, a node test, and a predicate. If all three components are present, the form of a location step is:

axis::nodetest[predicate]

For example:

child::person[attribute::birthdate <= "1951-06-18"]

says to start at the context node, locate all its children named "person", and from among those child nodes select only those with a birthdate attribute which is less than or equal to "1951-06-18".

Note that the predicate portion of this location step itself contains a location step, attribute::birthdate, but that the predicate as a whole does not constitute a location step. For more information, see Differences between XPath Expressions and XSLT Patterns.

Note   In the remainder of this topic, we will use the XPath abbreviated syntax for axes and node tests. For instance, with the abbreviated syntax, the above location step can be more concisely represented as:
person[@birthdate <= "1951-06-18"]
For more information, see Using Abbreviations in XPath Expressions.