Accepted answer

Eric White just posted a blog article to do exactly that - convert XElement to XmlNode and back.

Check it out here.



I just going to create an extension method InnerXml to return me the innerXML


Try something like this:

var x = elem.Descendants();

This will return you all the descendants of the root node - if you want a specific one you can pass its name as a string parameter to this same method.

Edit: If you really need it as a string you can aggregate the nodes. Here is an extension method that will do the trick:

public static String InnerXml(this XElement source)
    return source.Descendants().Select(x => x.ToString()).Aggregate(String.Concat);

Related Query

More Query from same tag