When trying to parse various data from an xml file using powershell, it would be useful to be able to see which elements actually exist, for debugging, etc. Therefore, if I have something like this:
[xml]$xmldoc = Get-Content doc.xml
$node = $xmldoc.SelectSingleNode("contents/some/path/items/item[name='itemname']")
$items = $xmldoc.contents.some.path.items
write-host "items = [${items}], node = [${node}]"
I would like to see the contents of $ items and $ node, but all I get is System.Xml.XmlDocument or System.Xml.XmlElement. When I tried to use items.Value or items.InnerText, they appear blank, so how can I print the actual text of these elements?
source
share