/build/static/layout/Breadcrumb_cap_w.png

Edit XML with Powershell

I'm looking to edit an XML is Powershell.
I've been racking my head for a couple of days, and i can get close, but can't quite get done what i need.

This is what i have in the XML:

  -ConfigData xmlns="http://xml.avaya.com/endpointAPI">
  -version>1
  -parameter>
    -name>Language
    -value>en
      -/parameter>
  -parameter>
    -name>Server1
    -value>1.1.1.1
      -/parameter>
 -/ConfigData>

This is what i need:
 -ConfigData xmlns="http://xml.avaya.com/endpointAPI">
  -version>1
  -parameter>
    -name>Language
    -value>en
      -/parameter>
  -parameter>
    -name>Server1
    -value>1.1.1.1
      -/parameter>
  -parameter>
    -name>Sever2
    -value>1.1.1.2
      -/parameter>
 -/ConfigData>


Not sure how to get around this one.
My hang up seems to be releated to the duplication of the same element with no true Root Element.
Any help will be greatly appreciated.

0 Comments   [ + ] Show comments

Answers (1)

Posted by: anonymous_9363 7 years ago
Red Belt
1
You could use the Microsoft XML object model, 'Microsoft.XMLDOM' and its 'createElement' method.

I use an edited version of John McFadyen's XML class, IpXMLClass.vbs. Clearly, it's in VBS but you should be able to munge its functions into Powershell.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ