private void SynchronizeElements(XmlElement targetElement, XmlElement sourceElement)
{
foreach (XmlAttribute attr in sourceElement.Attributes)
{
if (targetElement.Attributes[attr.Name] == null)
targetElement.SetAttribute(attr.Name, attr.Value);
}
foreach (XmlElement sourceChild in sourceElement.SelectNodes("*"))
{
XmlNamespaceManager nm = new XmlNamespaceManager(new NameTable());
nm.AddNamespace("temp", sourceElement.NamespaceURI);
XmlElement targetChild = targetElement.SelectSingleElement(string.Format("temp:{0}", sourceChild.LocalName), nm);
if (targetChild == null)
{
targetChild = targetElement.OwnerDocument.CreateElement(sourceChild.Name, sourceChild.NamespaceURI);
targetElement.AppendElement(targetElement.OwnerDocument.ImportNode(sourceChild, true));
}
this.SynchronizeElements(targetChild, sourceChild);
}
}