I know there is no direct method of doing it but still..
Can we convert XElement
element into XmlNode
.
Options like InnerText
and
Based on BrokenGlass's answer, if you wish to embed the XmlNode to an XmlDocument, than use:
public static class MyExtensions
{
public static XmlNode ToXmlNode(this XElement element, XmlDocument xmlDoc = null)
{
using (XmlReader xmlReader = element.CreateReader())
{
if(xmlDoc==null) xmlDoc = new XmlDocument();
return xmlDoc.ReadNode(xmlReader);
}
}
}
Note: if you try to insert into a document a node, that is created by a different document, than it will throw an exception: "The node to be inserted is from a different document context."