orders.xml文档内容如下//该代码片段来自于:www.sharejs.com/codes/csharp/7775 C#代码 using System; using System.Xml; public class XPathSelectNodes { private static void Main() { // Load the document. XmlDocument doc = new XmlDocument(); doc.Load("orders.xml"); XmlNodeList nodes = doc.SelectNodes("/Order/Items/Item/Name"); foreach (XmlNode node in nodes) { Console.WriteLine(node.InnerText); } Console.ReadLine(); } } //该代码片段来自于:www.sharejs.com/codes/csharp/7775 Remarkable Office Supplies Electronic Protractor 42.99 Invisible Ink 200.25
The above is the detailed content of C#中通过xpath查找xml的指定元素的代码实例. For more information, please follow other related articles on the PHP Chinese website!