I am gathering some XML from a webservice, and I receive it formatted as:
<devices>
<device>
<hostname>name</hostname>
<SerialNumber>38xkf8</SerialNumber>
<Uptime units="seconds">603835</Uptime>
</device>
<device>
<hostname>name</hostname>
<SerialNumber>495dkf</SerialNumber>
<Uptime units="seconds">92548</Uptime>
</device>
</devices>
I can parse through the info, but when I try and access the seconds, I cannot seem to get the data I want. When I try to access the Uptime element:
$xml.Devices.Device.Uptime
units #text
----- -----
seconds 603835
seconds 92548
I cannot get just the #text value returned.
Edit:
The solution:
Select-Xml -Xml $xml -XPath "//Device" | %
{
$_.Node.Uptime.InnerText
}