} |
// destParent and sourceParent are from different XmlDocuments.
// This method will append the children of sourceParent to the destParent's children.
public static void TransferChildren(XmlDocument destDoc, XmlNode destParent, XmlNode sourceParent)
{
// Create a temporary element into which we will add the children.
XmlElement tempElem = destDoc.CreateElement("Temp");
tempElem.InnerXml = sourceParent.InnerXml;
foreach(XmlNode node in tempElem.ChildNodes)
destParent.AppendChild(node);
}
// This method will append the children of sourceParent to the destParent's children.
public static void TransferChildren(XmlDocument destDoc, XmlNode destParent, XmlNode sourceParent)
{
// Create a temporary element into which we will add the children.
XmlElement tempElem = destDoc.CreateElement("Temp");
tempElem.InnerXml = sourceParent.InnerXml;
foreach(XmlNode node in tempElem.ChildNodes)
destParent.AppendChild(node);
}
文章来源:http://ms.mblogger.cn/xuzhong/posts/16522.aspx