// 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; namespace E { public class Program { public static void Main(string[] args) { string s = @" 0 0 Room 1 This is room 1 North South 1 0 Room 2 This is room 2 East West "; XmlDocument doc = new XmlDocument(); doc.LoadXml(s); XmlNodeList xmlRooms = doc.SelectNodes("//rooms/room"); foreach (XmlNode xmlRoom in xmlRooms) { XmlNodeList xmlExits = xmlRoom.SelectNodes("exits/exit"); Console.WriteLine(xmlExits.Count); } } } }