Here are some examples of patterns:
-
para
matches anypara
element -
*
matches any element -
chapter|appendix
matches anychapter
element and anyappendix
element -
olist/item
matches anyitem
element with anolist
parent -
appendix//para
matches anypara
element with anappendix
ancestor element -
/
matches the root node -
text()
matches any text node -
processing-instruction()
matches any processing instruction -
node()
matches any node other than an attribute node and the root node -
id("W11")
matches the element with unique IDW11
-
para[1]
matches anypara
element that is the firstpara
child element of its parent -
*[position()=1 and self::para]
matches anypara
element that is the first child element of its parent -
para[last()=1]
matches anypara
element that is the onlypara
child element of its parent -
items/item[position()>1]
matches anyitem
element that has aitems
parent and that is not the firstitem
child of its parent -
item[position() mod 2 = 1]
would be true for anyitem
element that is an odd-numbereditem
child of its parent. -
div[@class="appendix"]//p
matches anyp
element with adiv
ancestor element that has aclass
attribute with valueappendix
-
@class
matches anyclass
attribute (not any element that has aclass
attribute) -
@*
matches any attribute