|
Answer» Select XML Nodes by NAME in c# code To FIND nodes in an XML file we will use XPath expressions. Now we use Method XmlNode.SelectNodes which will returns a LIST of nodes selected by the XPath string. Below is syntax and using of XML by example

Now comes to reading part we will use below code to read above XML
XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(myXMLExampleString); XmlNodeList xmlnList = xmldoc.SelectNodes("/Students/Student"); foreach (XmlNode xn in xmlnList) { string firstName = xn["FName"].InnerText; string LASTNAME = xn["LName"].InnerText; Console.WriteLine("Name: {0} {1}", firstName, lastName); }
The output is: Name: ADAM Sutro Name: Jim Carry
|