【问题标题】:How to parse this soap response [closed]如何解析这个肥皂响应[关闭]
【发布时间】:2011-12-29 08:30:36
【问题描述】:

我正在使用 API,我得到这样的响应:

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header>
</env:Header>
<env:Body>
<ns1:processRequestResponse xmlns:ns1='ejb.store.microsoft.com'>
<result>
<?xml version="1.0" encoding="UTF-8"?> <CRMMessage language="en_US" currency="USD"  isTrustedSAT="false" hostversion="1.00"><RequestCode>GetCustomer</RequestCode><ResponseCode>A</ResponseCode><ResultSet><ResultSetMetaData><RSColumn name="PrimaryPOSRef" type="string" nullable="true"></RSColumn><RSColumn name="FirstName" type="string" nullable="true"></RSColumn><RSColumn name="LastName" type="string" nullable="true"></RSColumn><RSColumn name="EmailAddress" type="string" nullable="true"></RSColumn><RSColumn name="MobilePhoneNumber" type="string" nullable="true"></RSColumn><RSColumn name="Gender" type="string" nullable="true"></RSColumn><RSColumn name="PostalCode" type="string" nullable="true"></RSColumn><RSColumn name="PMACode" type="string" nullable="true"></RSColumn></ResultSetMetaData><Rows><Row id="11551"><Col>0331200000000058</Col><Col>test</Col><Col>Test</Col><Col>test@test.com</Col><Col>0412345678</Col><Col>M</Col><Col>2000</Col><Col>test</Col></Row></Rows></ResultSet></CRMMessage> 
</result>
</ns1:processRequestResponse>
</env:Body>
</env:Envelope>

之间的部分有什么用处

<result></result>

我如何解析这个 XML?

【问题讨论】:

标签: php xml soap


【解决方案1】:

最简单直接的方法是将xml解析成数组,然后使用标签作为数组索引。你可以在这里找到一些与此相关的 php 类:

http://www.phpclasses.org/search.html?words=xml++array&restrict[0]=C&restrict[1]=B&restrict[2]=D&forums=F&go_search=1&advanced=1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 2019-11-09
    • 1970-01-01
    相关资源
    最近更新 更多