I have an XML file of the following format:
<xml>
<data>
<foo float="99.0"/>
<bar float="12.0"/>
<tribble bool="true"/>
...
<flibble int="1"/>
</data>
</xml>
If I fetch that data in Powershell, I can see all the child elements of data with a Get-Memeber:
> $xmlData = [xml](Get-Content myfile.xml)
> $xmlData.data | Get-Member
...
foo Property System.Xml.XmlElement ...
bar Property System.Xml.XmlElement ...
tribble Property System.Xml.XmlElement ...
...
And I can access each child element individually. But how would I iterate over all the children, processing them with pipes? I'd love to be able to write something like this:
> $xmlData.data.Children | ?{$_ -eq "foo"}
...But alas that's just wishful thinking.
EDIT: Ok so I can reflect on the properties like this:
> $xmlData.data | get-member -memberType Property | ?{$_.Name -eq "foo"}
But I can't then go from the property (above I'm operating on a MemberDefinition) to the actual child element. Or can I?