all groups > dotnet xml > june 2006 >
You're in the

dotnet xml

group:

Move node?


Move node? Patrick
6/29/2006 4:48:13 PM
dotnet xml:
Hi,

I have a xml file like this:

<?xml version="1.0"?>
<home>
<page name="Test1" id="1">
<page name="Pagetest1" id="2" src="test1.htm"></page>
<page name="pagetest3" id="3" src="test2.htm"></page>
</page>
<page name="Test2" id="4" src="test1.htm">
<page name="Test23" id="7" src="test1.htm">
<page name="pagetest1" id="10" src="test1.htm"></page>
</page>
<page name="Pagetest1" id="5" src="test1.htm"></page>
<page name="pagetest2" id="6" src="test1.htm"></page>
</page>
</home>

and i am trying to move up a node for instance node with id="6" or node
id="4", id="10" cant be moved up only able to move between the same levels.
(c#) (i also want to move nodes one step down when pressing another button)

i was trying somethign like:
singlenode = mdoc.selectsinglenode(xpath);

singleNode.ParentNode.InsertBefore(singleNode, singleNode);


Patrick

Re: Move node? Martin Honnen
6/29/2006 5:19:24 PM


[quoted text, click to view]


[quoted text, click to view]

Use
singleNode.ParentNode.InsertBefore(singleNode,
singleNode.PreviousSibling)
and
singleNode.ParentNode.InsertAfter(singleNode, singleNode.NextSibling)
for the other direction
--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button