HOME

XPath Tutorial
XPath HOME
XPath Intro
XPath Syntax
XPath Locations
XPath Expressions
XPath Functions
XPath Examples
Download XMLSpy here
Please visit our sponsors !

XPath Expressions

Previous Next

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


Previous Next

Jump to: Top of Page or HOME or Printer Friendly 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


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search