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 $data
, and var_dump($data)
gives me this:
object(SimpleXMLElement)#1 (33) {
["buyer-accepts-marketing"]=>
string(4) "true"
...
...
but calling var_dump($data->buyer-accepts-marketing)
gives me an error, and var_dump($data["buyer-accepts-marketing"])
gives me NULL. Calling var_dump($data->shipping-address->children())
gives me an error.
going like this:
foreach($data as $item) {
var_dump($item);
}
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
$data->billing-address->postal-code;
...
$data->shipping-address->postal-code;
...
and can just go
address($data->billing-address);
address($data->shipping-address);
etc.