special character | meaning |
---|---|
* | all direct children |
// | all descents |
. | current node |
.. | parent node |
@name | select attribute name |
@* | select all attributes |
[n] | Nth node of nodelist, array getItem |
[filter expression] | filter |
[@name="somevalue] | select node with certain attribute |
<table name="Person"> <column name="id" type="long"> <filter> max < 100</filter> </column> <column name="title" type="string" max="50"> <pattern> [a-z]{1,6} </pattern> </column> <column name="createDate" type="date"> <filter> count < 10</filter> </column> </table>
xpath expression | result | explain |
---|---|---|
. | table node | current node |
.//column | all 3 "column" nodes | all descent nodes of "column" |
* | the root "table" | select all elements of the context node |
table/* | all 3 "column" nodes | select all child nodes of "table" node |
table/*[1] | the first "column" node | select the first node of all children nodes of "table" |