如何解析这个soap响应

时间:2011-11-15 09:14:25

标签: php xml soap

我正在使用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?

1 个答案:

答案 0 :(得分:0)

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

http://www.phpclasses.org/search.html?words=xml++array&restrict [0] = C&安培;限制[1] = B&安培;限制[2] = d&安培;论坛= F&安培; go_search = 1&安培;高级= 1