How do i extract the data from that xml object which is a value of a certain array:
Array ( [Title] => SimpleXMLElement Object (
[0] => The Key of Life; A Metaphysical Investigation )
[ASIN] => SimpleXMLElement Object ( [0] => 0982385099 ) ...
say $X is the object, so to print
The Key of Life; A Metaphysical Investigation
you do:
echo $X->Title[0]
Do string typecasting of the object.
$variable = (string) $FieldValue[0];
That would work, as SimpleXml has all the children in object type and not string.
It's important to understand that you're not working with an array — you're working with a SimpleXMLElement object, which is not the same.
$array['key']['subkey']
, you would do $xml->tag->subtag
. [0]
. It's assumed. You can convert SimpleXMLElement objects into true associative arrays in PHP 5.2 or newer with:
$array = json_decode(json_encode($xml), true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.