HomeFunctional XPathExamples

XPath

XPathDescription
paraselects the 'para' element children of the context node
*selects all element children of the context node
text()selects all text node children of the context node
node()selects all the children of the context node, whatever their node type
*/paraselects all para grandchildren of the context node
@nameselects the 'name' attribute of the context node
@*selects all the attributes of the context node
form: .//paraselects the 'para' element descendants of the context node
self::paraselects the context node if it is a 'para' element; otherwise selects nothing
self::elemselects the context node if it is an 'elem' element; otherwise selects nothing
//selects the context node, all the children (including attribute nodes) of the context node, and all the children of all the (element) descendants of t he context node. This is almost a powerset of the context node.
div//paraselects the 'para' element descendants of the 'div' element children of the context node
//olist/itemselects all the 'item' elements that have an 'olist' parent (which is not root) and that are in the same document as the context node
//td/@alignselects 'align' attributes of all 'td' elements
//td[@align]selects all 'td' elements that have an attribute 'align'
//td[@align="right"]selects all 'td' elements that have an attribute align="right"
para[1]selects the first 'para' child of the context node
para[last()]selects the last para child of the context node
table/tr[2]/td[3]selects the third td of the second tr of the table
para[@type='warning'][5]selects the fifth 'para' child of the context node that has a type attribute with value warning
para[5][@type='warning']selects the fifth 'para' child of the context node if that child has a 'type' attribute with value 'warning'
chapter[title='Introduction']selects the 'chapter' children of the context node that have one or more 'title' children with string-value equal to 'Introduction'
chapter[title]selects the 'chapter' children of the context node that have one or more 'title' children
HomeFunctional XPathExamples