Mega Code Archive

 
Categories / C# / XML
 

Get XML Elements By Tag Name

using System; using System.Xml; public class FindNodesByName {     private static void Main() {         // Load the document.         XmlDocument doc = new XmlDocument();         doc.Load("books.xml");         // Retrieve all prices.         XmlNodeList nodeList = doc.GetElementsByTagName("B");         foreach (XmlNode node in nodeList) {             Console.WriteLine(node.ChildNodes[0].Value);         }     } } // books.xml /* <books>   <A property="a">     <B>text</B>     <C>textg</C>     <D>99999</D>   </A> </books> */