Hi, just a simple question,
I have XmlDocument, two XmlNodes and I want to swap them in the
document... how to do that?
Any optimalizations these two will be siblings?
Anant - 25 Sep 2006 13:32 GMT
Hi,
You can use a temporary node and copy the contents of first into
this temp node. Then remove the first node and append the temp node at
last of the xmlDocument.
Hope i got your problem.
Martin Honnen - 25 Sep 2006 14:21 GMT
> I have XmlDocument, two XmlNodes and I want to swap them in the
> document... how to do that?
Try
XmlNode sibling = xmlNode1.NextSibling;
if (sibling != null) {
xmlNode2.ParentNode.InsertBefore(xmlNode1, xmlNode2);
sibling.ParentNode.InsertBefore(xmlNode2, sibling);
}
else {
XmlNode parent = xmlNode1.ParentNode;
xmlNode2.ParentNode.InsertBefore(xmlNode1, xmlNode2);
parent.AppendChild(xmlNode2);
}

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/