XPath Operators


XPath expressions can return node-sets, strings, booleans, and numbers.


XPath Operators

The following operators can be used in XPath expressions:

Operator Description Example Return Value
| Computes two node-sets //book | //cd Returns the node-set that contains both book and cd elements
+ Addition 6 + 4 10
- Subtraction 6 - 4 2
* Multiplication 6 * 4 24
div Division 8 div 4 2
= Equal price=9.80

Returns true if price is 9.80.

Returns false if price is 9.90.

!= Not equal price!=9.80

Returns true if price is 9.90.

Returns false if price is 9.80.

< Less than price<9.80

Returns true if price is 9.00.

Returns false if price is 9.90.

<= Less than or equal to price<=9.80

Returns true if price is 9.00.

Returns false if price is 9.90.

> Greater than price>9.80

Returns true if price is 9.90.

Returns false if price is 9.80.

>= Greater than or equal to price>=9.80

Returns true if price is 9.90.

Returns false if price is 9.70.

or or price=9.80 or price=9.70

Returns true if price is 9.80.

Returns false if price is 9.50.

and and price>9.00 and price<9.90

Returns true if price is 9.80.

Returns false if price is 8.50.

mod Computes the remainder of a division 5 mod 2 1
Other extensions