Other Operators
Other operators available in XPath 2.0 include the following:
Operators | Effect |
---|---|
+, -, *, div, mod, idiv | Arithmetic on numbers, dates, and durations |
=, !=, <, >, <=, >= | General comparison: compare arbitrary sequences. The result is true if any pair of items, one from each sequence, satisfies the comparison |
eq, ne, lt, gt, le, ge | Value comparison: compare single items |
is | Compare node identity: true if both operands are the same node |
<<, >> | Compare node position, based on document order |
union, intersect, except | Compare sequences of nodes, treating them as sets, returning the set union, intersection, or difference |
and, or | boolean conjunction and disjunction. Negation is achieved using the not function. |
to | defines an integer range, for example 1 to 10 |
instance of | determines whether a value is an instance of a given type |
cast as | converts a value to a given type |
castable as | tests whether a value is convertible to a given type |
Conditional expressions may be written using the syntax if (A) then B else C
.
XPath 2.0 also offers a for
expression, which is a small subset of the FLWOR expression from XQuery. The expression for $x in X return Y
evaluates the expression Y
for each value in the result of expression X
in turn, referring to that value using the variable reference $x
.
Read more about this topic: XPath 2.0