简体   繁体   中英

RESTFUL web service response parsing issue

I am getting the restful web service response as well. But I am not able to parse it properly

my code looks like this

include 'RestClient.class.php';

error_reporting(E_ALL);

// Client Profile



$url = "http://localhost/lgen/index.php/api/client";

$ex = RestClient::get($url,array('requestType' =>'viewClientProfile', 
                                                        'username' => 'uname', 
                                                                 'pass' =>'pass'));

echo $response = $ex->getResponse();

$xml = simplexml_load_string($response);

when print $response I am getting data on browser but while trying to parse it am not getting any kind of data

echo $response = $ex->getResponse();

You are creating and echoing a variable at the same time.

Try this:

$xml = simplexml_load_string($ex->getResponse());
var_dump($xml);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM