doukuipei9938 2011-07-20 15:04
浏览 18
已采纳

如何在PHP中解析复杂的XML-RPC结构?

Here is my XML object: http://pastebin.com/0L8vf0ja Which was created from:

<?xml version="1.0" encoding="utf-8"?>
<methodResponse><params><param><value><struct><member><name>result</name><value><struct><member><name>application_instance_id</name><value><i4>89</i4></value></member></struct></value></member><member><name>status</name><value><i4>0</i4></value></member></struct></value></param></params></methodResponse>

I know upto this level:

 $ApplicationInstanceID = (int)(string)$data->params->param->value->struct->member-> 

But from here, as you see in the pastebin, it becomes an array of objects - and I am not sure how to proceed.

Any ideas, please?

  • 写回答

4条回答 默认 最新

  • douyu3145 2011-07-20 15:11
    关注

    By accessing it as an array:

    $x = '<root><child><foo>23</foo><foo>34</foo></child></root>';
    $xml = new SimpleXMLElement($x);
    var_dump($xml->child->foo[0]);
    var_dump($xml->child->foo[1]);
    

    But, if you have it enabled, the xmlrpc_decode function is perhaps easier to use.

    var_dump(xmlrpc_decode($yourxml));
    array(2) {
      ["result"]=>
      array(1) {
        ["application_instance_id"]=>
        int(89)
      }
      ["status"]=>
      int(0)
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度