douze2890241475 2011-08-17 18:12
浏览 140
已采纳

从SOAP响应中解析XML

I'm trying to figure it out how to parse a XML reponse, but have no luck, what I needs is the record sections:

<env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:header/>
<env:body>
<ns2:getcalllogreportresponse xmlns:ns2="http://service.admin.ws.five9.com/">
<return>
<header>
<values>
<data>DATE</data>
<data>TIME</data>
<data>DNIS</data>
<data>ANI</data>
<data>CALL TYPE</data>
<data>CAMPAIGN</data>
<data>AGENT</data>
<data>DISPOSITION</data>
<data>SKILL</data>
<data>DURATION</data>
<data>BILL TIME (ROUNDED)</data>
<data>HOLD TIME</data>
<data>QUEUE WAIT TIME</data>
<data>HANDLE TIME</data>
<data>RATE</data>
<data>COST</data>
</values>
</header>
<records>
<values>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true">...</data>
</values>
</records>
<records>...</records>
<records>...</records>
<!--...-->

I am using PHP, but totally new to XML and SOAP. Thanks.

  • 写回答

1条回答 默认 最新

  • dongzhuoxie1244 2011-08-17 18:50
    关注

    That's because you shouldn't do soap requests or responses manually. You use a library like SoapClient by giving it a WSDL file (which should be made available to you by whatever service you are trying to access). SoapClient takes this WSDL file and returns an object to you that has pretty little methods which you can call to interact with the service. If soap seems hard, manual or stupid, then (as you suspected) you are doing it wrong. I'm glad you asked though, as I've come across teams of developers who made this mistake and spent 6 months building classes to manually interface with a SOAP service.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记