Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XPath Reference

Predicates

A predicate is an XPath expression that filters a node-set with respect to an axis and produces a new node-set. This filtering process involves sequentially evaluating the predicate against each node in the node set. Each time that the predicate is evaluated against a node:

This last context, that of the context node in the node-set, is relative to the direction that the axis specified in the location step navigates the document tree. Typically, an axis navigates the tree in either a forward or reverse direction:

As to the remaining axes, the self:: and parent:: axes return a single node. Therefore, the designation of forward or reverse does not make sense for these two axes. There is no order defined for the attribute:: and namespaces:: axes; so they too are neither forward nor reverse axes.

Selecting the Nodes

A predicate expression evaluates to either a numeric or Boolean value.

If the predicate results in a number, XPath compares that number to the context position of the context node. If the number and the position are the same (that is, the context node is in the appropriate position in the tree), the predicate evaluates to true and the context node is included in the new node-set. Otherwise, the context node is excluded from the new node-set.

If the predicate does not result in a number, XPath uses the boolean function to convert the result to a Boolean value. For example, the predicate [genre='Computer'] results in a node-set. If the context node has a child <genre> element with the content Computer, this predicate evaluates to true and the context node is included in the new node-set. Otherwise, the context node is excluded from the new node-set.

Note   A numeric predicate [x] is equivalent to the Boolean predicate [position()=x].

See Also

Location Steps | Axes | Node Tests