Find Elements with an XPath Search : XPath : XML C# Source Code


Custom Search

C# Source Code » XML » XPath »

 

Find Elements with an XPath Search









    


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>



*/
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML
» XPath