// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Linq; using System.Xml.Linq; namespace E { public class Program { public static void Main(string[] args) { XDocument doc = new XDocument(); XElement all = new XElement("all"); for(int i = 0; i < 5; i++) { all.Add(new XElement("one", "Element #" + (i + 1))); } doc.Add(all); doc.Save(@"C:\test5.xml"); } } }