I am totally stumped. I have managed to use simpleXML and XPATH to get this far.. now I am trying to neatly extract the keys and values from the following XML string. Trouble is I cannot figure out how to do it so that the number of [reagents] does NOT matter. Some strings will have 1 [reagent] some 15.
XML as I can access it:
Code:
<product id="12049" name="Corn Bread" icon="INV_Corn_09" minCount="1" maxCount="1">
<reagent id="4339" name="Corn Meal" quality="1" icon="INV_Baking_03" count="2" />
<reagent id="4291" name="Flour" quality="1" icon="INV_Baking_02" count="3" />
</product>
Code:
SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 12049
[name] => Corn Bread
[icon] => INV_Corn_09
[minCount] => 1
[maxCount] => 1
)
[reagent] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 4339
[name] => Corn Meal
[quality] => 1
[icon] => INV_Baking_03
[count] => 2
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 4291
[name] => Flour
[quality] => 1
[icon] => INV_Baking_02
[count] => 3
)
)
)
)
Can someone point me in the right directon? This is mainly for learning and I am a novice.