XPath is the W3C's general query language specification for addressing parts of an XML document. In this sample we are going to load an XmlDocument with the sample
perform an XPath query on XML and navigate over the selected nodes using an XmlNavigator. The sample code below illustrates the <b>Select</b> method that
applies an XPath expression.<div>
<div class="code">
<xmp>
XmlDocument xmldocument = new XmlDocument();
xmldocument.Load (m_Document);
DocumentNavigator navigator = new DocumentNavigator(xmldocument);
The <b>PushPosition</b> method remembers the current position of the XmlNavigator on a stack. The selection state however, is not remembered. You can later
return to this position by calling the <b>PopPosition</b> method. This enables you to move through the document using one select query and then return to a
known position, to perform another query. In other words, PushPosition remembers the node you were on when called, so that when you call PopPosition, you can
be taken back to that node. The output from these queries is shown.</div>
<div class="code">
<xmp>
XPath query: descendant::book/price
Element<price>8.99
Element<price>11.99
Element<price>9.99
XPath query: //book[last()]/@ISBN/text()
Text<#text>1-861001-57-6
</xmp>
</div>
<H4>Summary</H4>
<OL>
<LI>XPath is the W3C's general query language specification for addressing parts of an XML document and is a powerful XML query language.
<LI>The Select method applies the XPath query to the XML document.
<LI>The MoveToNextSelected method moves between the nodes returned from the XPath query.
<LI>The PushPosition method remembers the current position of the XmlNavigator on a stack. The selection state however, is not remembered. You can later
return to this position by calling the PopPosition method.