Getting an attribute from xml based associative array

nulleds

New Member
I have a xml parser that returns an associative array. Here's the structure:\[code\]<addresses id="123"> <anonymous-address> <test>data 1 </test> </anonymous-address></addresses>print_r($this->params) will return Array( [addresses] => Array ( [id] => 123 [anonymous-address] => Array ( [0] => Array ( [test] => Array ( [VALUE] => data 1 )))))\[/code\]This array then gets passed through list() as:\[code\]list($root, $data) = $parsedXML;\[/code\]Then I attempt to get an id attribute from root and read to do it this way:\[code\]$id = $data[$root]['id'];\[/code\]Edit: This works for all but one $root value which it 400's for. This case of the switch ($root) has the same code as the others, so I have no idea why it errs only there.var_dump($root, $data) outputs\[code\]string (9) "addresses"array(1) { ["addresses"]=> array(2) { ["id"]=> string(3) "123" ["anonymous-address"]=> array(1) { ["VALUE"]=> string(7) "data 1 " } }}\[/code\]
 
Back
Top