I have an attribute "Count" in my xml , and when I am trying to access the values of the attribute it giving the count of the array
$Count = $xml.Para.Lic.Counter.Count
Any suggestions would be really helpful
I have an attribute "Count" in my xml , and when I am trying to access the values of the attribute it giving the count of the array
$Count = $xml.Para.Lic.Counter.Count
Any suggestions would be really helpful
You can use single quotes around names:
$Count = $xml.Para.Lic.Counter.'Count'
However, if 'Counter' is an array, you need to access an instance to get the attribute value:
$Count = $xml.Para.Lic.Counter[0].Count
Both of these work. Maybe there is something else wrong with your XML?
$xml = Get-Content test.xml
$xml.catalog.counter.Count
$xml.catalog.counter.'Count'
Loading the following test.xml
<?xml version="1.0"?>
<catalog>
<counter count="150">
</counter>
</catalog>