alnorth29
alnorth29

Reputation: 3602

What's the XDocument equivalent of XmlDocument.ImportNode?

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?

Upvotes: 3

Views: 1468

Answers (1)

Oded
Oded

Reputation: 499112

There is no equivalent as XDocument doesn't have the notion of the document context that XmlDocument has.

You can simply add an XElement to the document, wherever that element came from.

See Alternative of <XMLdocument>.ImportNode on the MSDN forums.

Upvotes: 7

Related Questions