public SelectSingleNode ( |
||
expression | ||
return |
public virtual System.Xml.XPath.XPathNavigator SelectSingleNode(string xpath);
XmlDocument doc = new XmlDocument(); doc.Load("book.xml"); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator title = nav.SelectSingleNode("//book/title"); Console.WriteLine(title.Value);
XmlDocument doc = new XmlDocument(); doc.Load("book.xml"); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator price = nav.SelectSingleNode("//book[isbn='9780132350884']/price"); Console.WriteLine(price.Value);This code uses SelectSingleNode to find the first price node in the book.xml document that has an isbn child node with the value "9780132350884", and then outputs its value. These examples require the System.Xml.XPath.dll assembly, which is part of the .NET Framework.
public SelectSingleNode ( |
||
expression | ||
return |