Example: Results of XPath Expressions
Path Expression
|
Result
|
bookstore
|
Selects all nodes with the name "bookstore"
|
/bookstore
|
Selects the root element bookstore. If the path starts
with a slash ( / ) it always represents an absolute path to an element!
|
bookstore/book
|
Selects all book elements that are children of bookstore
|
//book
|
Selects all book elements no matter where they are in the
document
|
bookstore//book
|
Selects all book elements that are descendant of the
bookstore element, no matter where they are under the bookstore element
|
//@lang
|
Selects all attributes that are named lang
|
/bookstore/*
|
Selects all the child nodes of the bookstore element
|
//*
|
Selects all elements in the document
|
//title[@*]
|
Selects all title elements which have any attribute
|
Example: Results of XPath Expressions
- An XPath expression returns either a node-set, a string, a Boolean, or a number
- The list of operators used in an XPath expression are