Using LINQ to XML API to Create an XML Document and Adding Some Structure
using System; using System.Linq; using System.Xml.Linq; using System.Collections.Generic; class Program// w ww. j av a2 s. co m { static void Main(string[] args){ XDocument xDocument = new XDocument( new XElement("Books", new XElement("Book", new XAttribute("type", "Author"), new XElement("FirstName", "Joe"), new XElement("LastName", "Ruby")))); Console.WriteLine(xDocument.ToString()); } }