soycharliente Posted June 25, 2010 Share Posted June 25, 2010 I'm using a SoapClient to talk to another server and send/receive information. When making a web service call to get some information, it is returned formated like this: stdClass Object ( [information] => <xml>......</xml> ) I am getting an error when I simply try to grab the information via a SimpleXMLElement. The error says: Fatal error: Cannot use object of type stdClass as array in /file.php on line 12 How can I convert the format I'm getting back so that I can walk the XML tree? I hope this makes sense. Thanks. Link to comment https://forums.phpfreaks.com/topic/205861-stdclass-to-array/ Share on other sites More sharing options...
Mchl Posted June 25, 2010 Share Posted June 25, 2010 get information property of this object $xml = $object->information; Link to comment https://forums.phpfreaks.com/topic/205861-stdclass-to-array/#findComment-1077245 Share on other sites More sharing options...
soycharliente Posted June 25, 2010 Author Share Posted June 25, 2010 Works. Thanks! $response = $object->information; $xml = new SimpleXMLElement($response); $path = $xml->value->data->list->files; print_r($path); Link to comment https://forums.phpfreaks.com/topic/205861-stdclass-to-array/#findComment-1077247 Share on other sites More sharing options...
agmichaca Posted July 6, 2011 Share Posted July 6, 2011 Interesting, What happened if the answer of the WS has this structure: object(stdClass)[2] public 'generarCFDIPruebaResult' => object(stdClass)[3] public 'string' => array 0 => string 'True' (length=4) 1 => string '' (length=0) 2 => string 'Z' (length=1) 3 => string '<xml>...<xml> I can not use: $response = object->3; What can I do? Thanks Link to comment https://forums.phpfreaks.com/topic/205861-stdclass-to-array/#findComment-1238868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.