473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

swap nodes

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?

Sep 22 '06 #1
2 1759
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.

Sep 25 '06 #2


Jan Kucera wrote:

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);
}

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: sneill | last post by:
I know its possible to dynamically remove elements from the DOM, but rather than deleting them forever, is it possible to 'capture' them and save them as an object variable so they can be reused...
1
by: Sasha | last post by:
How can I swap two xml nodes that belong to the same parent? Examples would be great! Thank you, Sasha
1
by: Daniel Lidström | last post by:
Hi, is there a method somewhere in the framework for swapping two pointers? -- Daniel A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad...
12
by: Eugen J. Sobchenko | last post by:
Hi! I'm writing function which swaps two arbitrary elements of double-linked list. References to the next element of list must be unique or NULL (even during swap procedure), the same condition...
3
by: Sam | last post by:
Hi, How can I swap positions and values of two nodes in a treeview ? Thx
10
by: Atlas | last post by:
To swap to nodes in list, changing pointers is enough. But the stl swap method seems to copy their values, doesn't it?
4
by: Niels Dekker (no reply address) | last post by:
When calling swap as follows (as recommanded in Effective C++, 3rd Edition, by Scott Meyers), what swap is chosen to be called? using std::swap; swap(a, b); Suppose there is a global ::swap...
9
by: ma740988 | last post by:
Consider: # include <vector> # include <iostream> # include <cstdlib> # include <ctime> bool ispow2i ( double n ) {
19
by: Krishanu Debnath | last post by:
Hello, I have a call to hash_map::clear() function which takes long time. someClass::someFunction() { // typedef hash_map<name_id, uintMp; // Mp p; // assuming proper namespace, hash...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.