Mega Code Archive

 
Categories / C# / XML
 

Selects a list of nodes matching the XPath expression

using System; using System.IO; using System.Xml; public class Sample {   public static void Main() {     XmlDocument doc = new XmlDocument();     doc.Load("booksort.xml");     XmlNodeList nodeList;     XmlNode root = doc.DocumentElement;     nodeList=root.SelectNodes("descendant::book[author/last-name='Austen']");     foreach (XmlNode book in nodeList)     {       book.LastChild.InnerText="15.95";     }     doc.Save(Console.Out);   } }