using System; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; public class MainClass { public static void Main() { var bench = new XElement("bench", new XElement("A", new XElement("B", "H"), new XElement("B", "R") ), new XElement("A", new XElement("B", "S"), new XElement("C", "N") ), new XComment("comment") ); foreach (XElement e in bench.Elements()) Console.WriteLine(e.Name + "=" + e.Value); } }