// 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 oldxml = @" BMW Type1 Mercedes Type2 "; XDocument olddoc = XDocument.Parse(oldxml); XDocument newdoc = new XDocument(new XElement("Biler", from bil in olddoc.Root.Elements("Bil") select new XElement("Bil", new XAttribute("Mærke", bil.Element("Mærke").Value.Trim()), new XAttribute("Hjul", bil.Element("Hjul").Value.Trim())))); newdoc.Save(Console.Out); } } }