please ignore the semantics of the XML data. I want to scan the whole xml file and grab only banana values and store them as an array in PHP.
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<fruits>
<fruit id="1" >
<aisle1>
<apple>aa</apple>
<banana>ab</banana>
<cherry>ac</cherry>
<damson>ad</damson>
</aisle1>
<aisle2>
<apple>none</apple>
<banana>3708650582321691833</banana>
<cherry>none</cherry>
<damson>none</damson>
</aisle2>
<aisle3>
<apple>none</apple>
<banana>3708650582321691833</banana>
<cherry>none</cherry>
<damson>none</damson>
</aisle3>
</fruit>
<fruit id="2" >
<aisle1>
<apple>none</apple>
<banana>3708650582321691833</banana>
<cherry>none</cherry>
<damson>none</damson>
</aisle1>
<aisle2>
<apple>none</apple>
<banana>3708650582321691833</banana>
<cherry>none</cherry>
<damson>none</damson>
</aisle2>
<aisle3>
<apple>none</apple>
<banana>3708650582321691833</banana>
<cherry>none</cherry>
<damson>none</damson>
</aisle3>
</fruit>
</fruits>
Can xPath allow me to do this? I currently have:
$xml->xpath("//fruits//fruit//bananas->text()";
Thanks.
No comments:
Post a Comment