What's the best way to move "a child up" in a C# XmlDocument?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-03-13T03:28:30Z Indexed on 2010/03/13 3:37 UTC
Read the original article Hit count: 321

Filed under:
|

Hi everyone,

Given an xml structure like this:

<garage>
 <car>Firebird</car>
 <car>Altima</car>
 <car>Prius</car>
</garage>

I want to "move" the Prius node "one level up" so it appears above the Altima node. Here's the final structure I want:

<garage>
 <car>Firebird</car>
 <car>Prius</car>
 <car>Altima</car>
</garage>

So given the C# code:

XmlNode priusNode = GetReferenceToPriusNode()

What's the best way to cause the priusNode to "move up" one place in the garage's child list?

Thanks!

-Mike

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml