Selecting attributes in xml using xpath in powershell
These two lines should suffice:
[xml]$xml = Get-Content 'C:\path\to\your.xml'$xml.selectNodes('//person') | select Name
How about one line?
Select-XML -path "pathtoxml" -xpath "//person/@name"
I'm not sure what $hub is, and you started your code from the middle so it's not clear if you properly set $file to an XmlDocument object, but I think this is what you want:
[System.Xml.XmlDocument]$file = new-object System.Xml.XmlDocument$file.load(<path to XML file>)$xml_peoples= $file.SelectNodes("/peoples/person")foreach ($person in $xml_peoples) { echo $person.name}