I’m migrating some code from using XmlDocument to using XDocument. As part of this code I need to add an element from one document into another document. With an XmlDocument I could do this using ImportNode, how do I do it with an XDocument?
Share
There is no equivalent as
XDocumentdoesn’t have the notion of the document context thatXmlDocumenthas.You can simply add an
XElementto the document, wherever that element came from.See Alternative of
<XMLdocument>.ImportNodeon the MSDN forums.