I want to merge two XmlDocuments by inserting a second XML doc to the end of an existing Xmldocument in C#. How is this done?
I want to merge two XmlDocument s by inserting a second XML doc to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this:
Note that this ignores the document element itself of document B – so if that has a different element name, or attributes you want to copy over, you’ll need to work out exactly what you want to do.
EDIT: If, as per your comment, you want to embed the whole of document B within document A, that’s relatively easy:
This will still ignore things like the XML declaration of document B if there is one – I don’t know what would happen if you tried to import the document itself as a node of a different document, and it included an XML declaration… but I suspect this will do what you want.