.Net supports XPath queries through classes like XPathDocument, XPathNavigator and XPathIterator.
XPath expressions and their meaning.
Following are the expressions which can be used for entire document search. This is an absolute search not relevant to the current node in the XML document.
| Expression | Description |
| Nodename | Selects all child nodes of the named node |
| / | Selects from the root node |
| // | Selects nodes in the document from the current node that match the selection no matter where they are |
| . | Selects the current node |
| .. | Selects the parent of the current node |
| @ | Selects attributes |
| * | Matches any element node |
| @* | Matches any attribute node |
| node() | Matches any node of any kind |
Following are the XPath axes expressions which can be used to search the XML document hierarchically. This search is relative to the current node in the XML document as it sounds from there names. When we are traversing the document we can use these expressions to get the required elements.
| XPath Axes | Description |
| ancestor | Selects all ancestors (parent, grandparent, etc.) of the current node |
| ancestor-or-self | Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself |
| attribute | Selects all attributes of the current node |
| child | Selects all children of the current node |
| descendant | Selects all descendants (children, grandchildren, etc.) of the current node |
| descendant-or-self | Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself |
| following | Selects everything in the document after the closing tag of the current node |
| following-sibling | Selects all siblings after the current node |
| namespace | Selects all namespace nodes of the current node |
| parent | Selects the parent of the current node |
| preceding | Selects everything in the document that is before the start tag of the current node |
| preceding-sibling | Selects all siblings before the current node |
| self | Selects the current node |
Following is the detailed XPath document from W3C Schools.
http://www.w3schools.com/xpath/xpath_intro.asp
Thanks
Prasad

No comments:
Post a Comment