xml - PowerShell: How to add XmlElement to a non-root element -


I'm having trouble adding an XmlElement to a non-root element in PowerShell.

Actually, this XML has been given:

   

I want to receive it

  & lt; Clubs & gt; & Lt; Club name = "Boca" status = "1" & gt; & Lt; Region & gt; Bombonera & lt; / Region & gt; & Lt; Region & gt; Bombonerita & lt; / Region & gt; & Lt; / Club & gt; & Lt; Club name = "racing" status = "19" & gt; & Lt; Region & gt; Cilindro & lt; / Region & gt; & Lt; / Club & gt; & Lt; Club name = "barracas" /> & Lt; / Clubs & gt;  

I create an element,

  $ new = $ clubs.CreateElement ("barracas")  

when I want to add this element to the non-root node i.e.

  $ clubs.clubs.club + = $ new  

I get

I try.
  "club" can not be set because XmlNode properties can only be used as string values ​​for setting.  

What am I missing?

AppendChild on the appropriate element method has options for appendbill, In which you allow more control of the location in the Dom Tree.

  $ club = $ xml.CreateElement ('club') $ club.SetAttribute ('name', 'barracas') $ xml.clubs.AppendChild ($ club)  < / Pre> 

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -