public static string MergeXML(string xml1, string xml2)
{
XmlDocument xmlDoc1 = new XmlDocument();
XmlDocument xmlDoc2 = new XmlDocument();
xmlDoc1.LoadXml(xml1);
xmlDoc2.LoadXml(xml2);
XmlNode newNode;
string mergedXML = string.Empty;
for (int j = 0; j <= xmlDoc2.DocumentElement.ChildNodes.Count - 1; j++)
{
newNode = xmlDoc1.ImportNode(xmlDoc2.DocumentElement.ChildNodes[j], true);
xmlDoc1.DocumentElement.AppendChild(newNode);
}
mergedXML = Functions.GetXmlString(xmlDoc1);
return mergedXML;
}
{
XmlDocument xmlDoc1 = new XmlDocument();
XmlDocument xmlDoc2 = new XmlDocument();
xmlDoc1.LoadXml(xml1);
xmlDoc2.LoadXml(xml2);
XmlNode newNode;
string mergedXML = string.Empty;
for (int j = 0; j <= xmlDoc2.DocumentElement.ChildNodes.Count - 1; j++)
{
newNode = xmlDoc1.ImportNode(xmlDoc2.DocumentElement.ChildNodes[j], true);
xmlDoc1.DocumentElement.AppendChild(newNode);
}
mergedXML = Functions.GetXmlString(xmlDoc1);
return mergedXML;
}
No comments:
Post a Comment