Reader Level:

Merge 2 XML files into single XML using C#

By Karthikeyan Anbarasan on Mar 17, 2011
This article gives a basic idea on how to merge 2 XML files into a single XML using C#.
  • 0
  • 0
  • 22650

This Article shows how to merge two XML files and make use of a single XML inorder to make the process simpler.

Here XMLDocument is used in order to transfer the nodes from one XML to the other. So first step is to open the XML using the XML Document as shown below

System.Xml.XmlDocument objFirstXML = new XmlDocument();
Similar way we open the second XML using the XMLDocument.
System.Xml.XmlDocument objSecondXML = new XmlDocument();
Here once we open the xml now search for the node and then append it to the main one
XmlNode objInsert = objFirstXML.SelectSingleNode("/XMLROOT/CHILD"); 
foreach( XmlNode objNode in objInsert.SelectNodes("/XMLROOT/CHILD/CHILDITEM")) 

Karthikeyan Anbarasan

Karthikeyan Anbarasan (Karthik) Microsoft MVP in ASP.NET/IIS Architecture is a blogger & Founder of, also he is a speaker and Technology geek in Microsoft products. Karthik is working as a Technical C... Read more

Personal Blog: