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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -