Table 3-1 shows the supported basic XPath operators.
Operator |
Description |
---|---|
/ |
Path (Children): the child operator ('/') selects from immediate children of the left-side collection. |
// |
Descendants: the descendant operator ('//') selects from arbitrary descendants of the left-side collection. |
* |
Collecting element children: an element can be referenced without using its name by substituting the '*' collection |
@ |
Attribute: attribute names are preceded by the '@' symbol |
[] |
Filter: You can apply constraints and branching to any collection by adding a filter clause '[ ]' to the collection. The filter is analogous to the SQL where clause with any semantics. The filter contains a query within it, called the sub-query. If a collection is placed within the filter, a Boolean “true” is generated if the collection contains any members, and a “false” is generated if the collection is empty. |
[n] |
Index: index is mainly use to find a specific node within a set of nodes. Enclose the index within square brackets. The first node is index 1. |
[-n] |
Backtrack index: return the element that is n-1 units from the last element. -1 means the last element, -2 is the next to last element. |
[m to n] |
Subscript: returns elements m through n, where m is the first index and n is the last index. |
text() |
Selects the text nodes of the current context node. |