views:

1479

answers:

1

HI,

Is there any 'correct' way to convert an XElement to an XmlNode in C# - LinqToXML makes it nice to build the required XML programmatically but SharePoint web services requires an XmlNode, so whats the best way to mix and match?

+9  A: 

Use CreateReader() and an XmlDocument like

XmlDocument myXmlNode = new XmlDocument();
using (XmlReader reader = myXElement.CreateReader())
{
    myXmlNode.Load(reader);
}

XmlDocument derives from XmlNode.

TToni