Home > Article > Backend Development > Code example for finding specified elements of xml through xpath in C#
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 Code example for finding specified elements of xml through xpath in C#. For more information, please follow other related articles on the PHP Chinese website!