Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php RESTFUL web服务响应解析问题_Php_Xml_Rest - Fatal编程技术网

Php RESTFUL web服务响应解析问题

Php RESTFUL web服务响应解析问题,php,xml,rest,Php,Xml,Rest,我也得到了RESTfulWeb服务响应。但我无法正确解析它 我的代码如下所示 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',

我也得到了RESTfulWeb服务响应。但我无法正确解析它

我的代码如下所示

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

打印$response时,我在浏览器上获取数据,但在尝试解析它时,没有获取任何类型的数据

echo $response = $ex->getResponse();
您正在同时创建和回显一个变量

试试这个:

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

那么问题是什么?您是否有任何错误?打印$response时,我在浏览器上获取数据,但在尝试解析数据时,我没有获取任何类型的数据我有一个类似78cytechqweasd123345456mnbzxControly2State2Country2的xml我如何使用简单的xml解析它?阅读并查看。嗨,Simone我可以打印响应,但无法解析它