XmlDocument.SelectSingleNode
using System;
using System.Xml;
using System.Xml.XPath;
public class XPathQuery {
public static void Main(string [] args) {
string filename = "inventory.xml";
string xpathExpression = "//inventory/items";
XmlDocument document = new XmlDocument( );
document.Load(filename);
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
XmlNode node = document.SelectSingleNode(xpathExpression);
node.WriteTo(writer);
writer.Close( );
}
}
Related examples in the same category