Mega Code Archive

 
Categories / C# / XML
 

Returns an XmlNodeList containing a list of all descendant elements that match the Name

using System; using System.IO; using System.Xml; public class Sample {   public static void Main()   {      XmlDocument doc = new XmlDocument();      doc.Load("data.xml");      XmlElement root = doc.DocumentElement;      XmlNodeList elemList = root.GetElementsByTagName("title");      for (int i=0; i < elemList.Count; i++)      {            Console.WriteLine(elemList[i].InnerXml);      }    } }