【问题标题】:RESTFUL web service response parsing issueRESTFUL Web 服务响应解析问题
【发布时间】:2012-11-20 09:44:25
【问题描述】:

我也得到了宁静的 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);

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

【问题讨论】:

  • 那么问题是什么?你有什么错误吗?
  • 当打印 $response 时我在浏览器上获取数据,但在尝试解析它时没有得到任何类型的数据

标签: php xml rest


【解决方案1】:
echo $response = $ex->getResponse();

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

试试这个:

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

【讨论】:

  • 我有一个像 78cytechqweasd这样的 xml >123345456mnbzxccontry2state2country2 如何使用简单的 xml 解析它?
  • 阅读Manual并查看Examples
  • 嗨 Simone 我可以打印响应但无法解析它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-30
  • 2023-04-09
相关资源
最近更新 更多