// 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.Collections.Generic; using System.Linq; using System.Xml; using System.Xml.Linq; namespace E { public class Program { public static void Main(string[] args) { string s = @" "; XDocument doc = XDocument.Parse(s); Dictionary dic = doc.Element("Colors").Element("FlagColors").Element("USA").Elements().ToDictionary(elm => int.Parse(elm.Attribute("order").Value), elm => elm.Name.LocalName); foreach(KeyValuePair kvp in dic) { Console.WriteLine(kvp.Key + " = " + kvp.Value); } } } }