I'm using an Amazon API to retrieve product information and the response (converted to an object using simplexml_load_string()
) looks like this:
SimpleXMLElement Object
(
[Items] => SimpleXMLElement Object
(
[Item] => SimpleXMLElement Object
(
[ASIN] => B00C9WDZIG
[ParentASIN] => B00C9WDZIG
)
)
)
The output of this:
var_dump($parsed_xml->Items->Item->ASIN);
var_dump($parsed_xml->Items->Item->ParentASIN);
is this:
object(SimpleXMLElement)[3]
string 'B00C9WDZIG' (length=10)
object(SimpleXMLElement)[4]
string 'B00C9WDZIG' (length=10)
I'm confused because var_dump()
is outputting objects instead of strings. Why is that? Aren't ASIN
and ParentASIN
string values inside of the third SimpleXMLElement
object?
In other words, I expected the output to be:
string 'B00C9WDZIG' (length=10)
string 'B00C9WDZIG' (length=10)
And I'm confused why it wasn't.
Can anyone explain this?