// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Xml; class MainClass { public static void Main(string[] args) { string result = ""; try { XmlDocument objXMLdoc = new XmlDocument(); objXMLdoc.Load(@"C:\test.xml"); XmlNodeList nodeList; XmlElement root = objXMLdoc.DocumentElement; nodeList = root.SelectNodes("//worldnews/newsdoc/latestnews"); foreach (XmlNode latestnews in nodeList) { XmlAttribute id = latestnews.Attributes["id"]; XmlAttribute name = latestnews.Attributes["name"]; Console.WriteLine(id.Value); Console.WriteLine(name.Value); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } }