// 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.Linq; using System.Xml.Linq; namespace E { public class Program { public static void Main(string[] args) { string s = @" AA BB "; XDocument doc = XDocument.Parse(s); foreach(var u in doc.Descendants("user")) { Console.WriteLine(u.Element("value").Value); } foreach(var u in doc.Element("login").Elements("user")) { Console.WriteLine(u.Element("value").Value); } foreach(var u in doc.Root.Elements("user")) { Console.WriteLine(u.Element("value").Value); } } } }