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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里