Powershell – Insert node between two others

Question:

I would like to insert a node between 2 others already existing.
In my script, I receive a xml variable and I would like to update this one.

Ex :

the result should be :

When I use a appendChild, the insert is done always done at the end…

An idea ?

Thanks !

Answer:

As @Grhm answered, you can do it by InsertAfter. I would recommend always to try to pipe it to Get-Member to get the hint.

Personally I think gm (or Get-Member) is the most useful cmdlet in PowerShell 😉

Source:

Powershell – Insert node between two others by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply