2

How replace XML Node from one XML document with another XML node from another XML Document. Please help..

0

1 Answer 1

4

You can use LINQ to Xml XElement.ReplaceWith method

// select node from one doc
XDocument xdoc1 = XDocument.Load(path_to_doc1);    
XElement one = xdoc1.Descendants("One").First(); 

// select node from another doc
XDocument xdoc2 = XDocument.Load(path_to_doc2);
XElement another = xdoc2.Descendants("Another").First(); 

// replace one xml node with another
one.ReplaceWith(another);
xdoc1.Save(path_to_doc1);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.