How to get just the root element from Xelement

You can try this in VB.NET

Dim elm as XElment = XElement.Parse(<Assembly name="3">
                                     <Component name="2" /> 
                                    </Assembly>)

Dim strName as string 
strName = elm.AncestorsAndSelf.First.Name

Code in C#

XElement elm = XElement.Parse("<Assembly name='3'><Component name='2' /></Assembly>");
string name =elm.AncestorsAndSelf().First().Name;

You can get the root element this way :

XDocument.Root

Here is an example of implementation :

XDocument doc = new XDocument(
new XComment("This is a comment."),
new XElement("Pubs", 
    new XElement("Book",
        new XElement("Title", "Artifacts of Roman Civilization"),
        new XElement("Author", "Moreno, Jordao")
    ),
    new XElement("Book",
        new XElement("Title", "Midieval Tools and Implements"),
        new XElement("Author", "Gazit, Inbar")
    )
),
new XComment("This is another comment.")
);
Console.WriteLine(doc.Root.Name.ToString());

link : http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.root.aspx