Search code examples
phpsimplexml

Extract data from an XML object


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 ) ...

Solution

  • 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.