Please visit our sponsors !
XPath Expressions
XPath supports numerical, equality, relational, and Boolean
expressions.
Numerical Expressions
Numerical expressions are used to perform arithmetic operations on numbers.
Operator |
Description |
Example |
Result |
+ |
Addition |
6 + 4 |
10 |
- |
Subtraction |
6 - 4 |
2 |
* |
Multiplication |
6 * 4
|
24 |
div |
Division |
8 div 4 |
2 |
mod |
Modulus (division remainder) |
5 mod 2 |
1 |
Note: XPath always converts each operand to a number before performing an
arithmetic expression.
Equality Expressions
Equality expressions are used to test the equality between two values.
Operator |
Description |
Example |
Result |
= |
Like (equal) |
price=9.80 |
true (if price is 9.80) |
!= |
Not like (not equal) |
price!=9.80 |
false |
Testing Against a Node-Set
If the test value is tested for equality against a node-set, the result is true
if the node-set contains any node with a value that matches the test value.
If the test value is tested for not equal against a node-set, the result is
true if the node-set contains any node
with a value that different from the test value.
The result is that the node-set can be equal and not equal at the same
time !!!
Relational Expressions
Relational expressions are used to compare two values.
Operator |
Description |
Example |
Result |
< |
Less than |
price<9.80 |
false (if price is 9.80) |
<= |
Less or equal |
price<=9.80 |
true |
> |
Greater than |
price>9.80 |
false |
>= |
Greater or equal |
price>=9.80 |
true |
Note: XPath always converts each operand to a number before performing
the evaluation.
Boolean Expressions
Relational expressions are used to compare two values.
Operator |
Description |
Example |
Result |
or |
or |
price=9.80 or price=9.70 |
true (if price is 9.80) |
and |
and |
price<=9.80 and price=9.70 |
false |
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|