XPath Absolute and Relative Paths
In XPath, there are two types of paths used specify the location of a node in XML documents.
These are absolute path and relative path.
An absolute path starts with root node or with
/bookstore/book: It will select book nodes within class root node.
/bookstore/book/author: It will select author of book node within class root node.
If location path starts with the node that we've selected then it is a relative path.
title: It selects title related to book nodes.
Selecting Several Paths
| operator in an XPath expression you can select several paths.
In the table below we have listed some example of path expressions and the result of the expressions:
|Selects all the title AND price elements of all book elements|
|Selects all the title AND price elements in the document|
|Selects all the title elements of the book element of the bookstore element AND all the price elements in the document|
You can learn more about Node Operators and Functions in our XPath Node Operators and Functions chapter.