Append XMl node


i’m trying to create a node and append it to the existing xml file using below powershell code.

[xml]$temp = Get-Content C:\temp\test.xml

$device = $temp.CreateElement(“device”)

$device.InnerXml = “$dev”



Here “$dev” has all the values to append in to xml file
part of xml file…where i would like to append the node…



















<TimeZoneName>(GMT-05:00) Eastern Time (US & Canada)</TimeZoneName>





In the above xml code, new node “Device” is saving above sqlServerRstOption, but it should be between vSSBackup and restoreSource nodes.
Is there any way we could do that ?
Please let me know your suggestions…
Thanks in advance

File attachments need to be .TXT filenames.

XML isn’t sensitive to order or sequence in the way you’re asking. The XML code in .NET isn’t worried so much how the XML looks to a human being, it worries about it being machine-readable. The machine doesn’t care what order nodes come in, so there’s no provision for inserting a node in a particular spot with regard to its siblings at the same level.

In other words, as far as the computer’s concerned, where it’s putting the new node is fine. It’s like in a SQL Server database. The physical order of the rows as they’re stored on disk doesn’t really matter, and you don’t really have control over it when you insert new rows.

Thanks Don…