Selecting attributes in xml using xpath in powershell -


i trying use powershell , xpath select name attribute shown in below xml example.

     $xml_peoples= $file.selectnodes("//people")       foreach ($person in $xml_peoples){             echo $person.attributes             #echo $person.attributes.name      } 

above code im running try , name, doesn't seem work. suggestions?

<peoples>     <person name='james'>         <device>             <id>james1</id>             <ip>192.192.192.192</ip>         </device>     </person> </peoples> 

thanks in advance!

i'm not sure $hub is, , started code middle it's not clear if set $file xmldocument object, think want:

[system.xml.xmldocument]$file = new-object system.xml.xmldocument $file.load(<path xml file>) $xml_peoples= $file.selectnodes("/peoples/person") foreach ($person in $xml_peoples) {   echo $person.name } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -