i have parse data web service returns xml through php. have no issues getting data having trouble accessing specific attribute. xml parsing looks when var_dump it.
object(simplexmlelement)#13 (2) { ["@attributes"]=> array(1) { ["label"]=> string(4) "11am" } ["value"]=> object(simplexmlelement)#14 (1) { ["@attributes"]=> array(1) { ["y"]=> string(6) "204.68" } } }
to element looping through xml , each element this
foreach($details $key){ foreach($key $value){ var_dump($value); } }
to access label part of element can echo $value['label'] having trouble accessing y element. appreciated!
the y
attribute on value
element, child node underneath current node. means there separate simplexmlelement
object on $value
. can access them both in foreach loop so:
foreach($details $key){ foreach($key $value){ $label = $value['label']; $y = $value->value['y']; } }
Comments
Post a Comment