Mega Code Archive

 
Categories / C# Tutorial / XML
 

Xpath Demo

using System; using System.Xml; using System.Collections.Generic; using System.Text;     class Program     {         static void Main(string[] args)         {             XmlDocument docItems = new XmlDocument();             docItems.Load("items.xml");             XmlNode thirdItem = docItems.SelectSingleNode("/items/item[2]");             Console.WriteLine("Third node is {0}", thirdItem.Attributes["name"].Value);         }     }