About XPath
Sunday, May 1, 2011
Labels:
About XPath
We will use the following XML document in the examples below.

Selecting Nodes
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
In the table below we have listed some path expressions and the result of the expressions:
Predicates
Predicates are used to find a specific node or a node that contains a specific value. Predicates are always embedded in square brackets.
In the table below we have listed some path expressions with predicates and the result of the expressions:
Selecting Unknown Nodes
XPath wildcards can be used to select unknown XML elements.
In the table below we have listed some path expressions and the result of the expressions:
Selecting Several Paths
By using the | operator in an XPath expression you can select several paths. In the table below we have listed some path expressions and the result of the expressions: