Find Elements with an XPath Search

image_pdfimage_print


   
 

using System;
using System.Xml;

public class XPathSelectNodes {

    private static void Main() {

        // Load the document.
        XmlDocument doc = new XmlDocument();
        doc.Load("books.xml");

        XmlNodeList nodes = doc.SelectNodes("/books/A/B");
            
        foreach (XmlNode node in nodes) {
            Console.WriteLine(node.InnerText);
        }
    }
}
/*
<books>
  <A property="a">
    <B>text</B>
    <C>textg</C>
    <D>99999</D>
  </A>
</books>



*/
           
         
     


This entry was posted in XML-RPC. Bookmark the permalink.