XDocument.Root Property returns the root element of the XML Tree for this document.
using System; using System.IO; using System.Linq; using System.Xml.Linq; using System.Xml; using System.Collections; using System.Collections.Generic; public class MainClass { public static void Main() { XDocument doc = new XDocument( new XComment("This is a comment."), new XElement("RootNode", new XElement("Book", new XElement("Title", "C#"), new XElement("Author", "No Name") ) ), new XComment("This is another comment.") ); Console.WriteLine(doc.Root.Name.ToString()); } }