2012-11-20 100 views
0

我也得到了宁静的Web服务响应。但我不能够正确地解析它RESTful Web服务响应解析问题

我的代码看起来像这样

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

当打印$回应我得到浏览器的数据,但在试图解析它我没有得到任何类型的数据

+0

有啥问题?你有没有得到任何错误? – Simone

+0

当打印$回应我得到浏览器的数据,但在试图解析它我没有得到任何类型的数据 – sree

回答

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

您正在同时创建和回显变量。

试试这个:

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

的我都喜欢 78骏龙 qwe asd 123 345 456 mnb zxc contry2state2 country2 如何使用简单的xml解析它? – sree

+0

阅读[Manual](http://php.net/manual/en/book.simplexml.php)并查看[Examples](http://www.php.net/manual/en/simplexml .examples-basic.php)。 – Simone

+0

嗨西蒙我可以打印回应,但无法解析它 – sree