Using simplexml, is it possible to get the children of a node based on the parent's attributes. For example, I want to get a list of the variants in myItem1 (output would be small, large)
Here is some psuedo code of what I'm after:
foreach($xml->xpath('//family[@name="myItem1"]')->variants->children() as $child) {
$child->getName()
}
(Of course this doesn't work, but hopefully it describes what I'm trying to do.)
Sample XML:
<library>
<family name="myItem1">
<variants>
<small>
...
</small>
<large>
...
</large>
</variants>
</family>
<family name="myItem2">
<variants>
<small>
...
</small>
<medium>
...
</medium>
</variants>
</family>
</library>
Thank you.