getting items from a SimpleXMLElement object

wertwrect

New Member
From what I can tell, a SimpleXMLElement is just an array of other SimpleXMLElements, plus some regular array values if there wasn't a tag nested in another tag.I have a SimpleXMLElement in a variable \[code\]$data\[/code\], and \[code\]var_dump($data)\[/code\] gives me this:\[code\]object(SimpleXMLElement)#1 (33) { ["buyer-accepts-marketing"]=> string(4) "true"......\[/code\]but calling \[code\]var_dump($data->buyer-accepts-marketing)\[/code\] gives me an error, and \[code\]var_dump($data["buyer-accepts-marketing"])\[/code\] gives me NULL. Calling \[code\]var_dump($data->shipping-address->children())\[/code\] gives me an error.going like this:\[code\]foreach($data as $item) { var_dump($item);}\[/code\]gives a whole bunch of SimpleXMLElement objects, but oddly enough, no strings or ints.What am I missing here? I want to take specific portions of it and pass them to a function, so for example, I don't have to go\[code\]$data->billing-address->postal-code;...$data->shipping-address->postal-code;...\[/code\]and can just go\[code\]address($data->billing-address);address($data->shipping-address);\[/code\]etc.
 
Back
Top