How can I achieve this:
<root>
<gallery name="First">
<picture active="1" detail="not shown"/>
<picture active="1" detail="not shown"/>
<picture active="0" detail="not shown"/>
</gallery>
<gallery name="Second">
<picture active="0" detail="not shown"/>
<picture active="1" detail="SHOW THIS ONE"/>
<picture active="1" detail="AND SHOW THIS ONE" />
</gallery>
</root>
I’m trying:
$myArray = $objXML->xpath('gallery[@name="Second"]/picture[@active=1]');
How can I change it to get the desired output?
Thanks, Andy
Your XPath is wrong. Either use
to match this node constellation from the root node only or
to match this node constellation anywhere in the document (slower)
Full working examples:
gives
and
gives