Php 解析soapxml文档
我有这个SOAP响应Php 解析soapxml文档,php,xml,soap,Php,Xml,Soap,我有这个SOAP响应 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <pkup:PickupPendingStatusResponse xmlns:pkup="http://www.ups.com/XMLSchema/XOLTWS/Pickup/v1.1">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<pkup:PickupPendingStatusResponse xmlns:pkup="http://www.ups.com/XMLSchema/XOLTWS/Pickup/v1.1">
<common:Response xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<common:ResponseStatus>
<common:Code>1</common:Code>
<common:Description>Success</common:Description>
</common:ResponseStatus>
</common:Response>
<pkup:PendingStatus>
<pkup:PickupType>01</pkup:PickupType>
<pkup:ServiceDate>20141006</pkup:ServiceDate>
<pkup:PRN>2929AONCALL</pkup:PRN>
<pkup:OnCallStatusCode>001</pkup:OnCallStatusCode>
<pkup:PickupStatusMessage>Received at dispatch</pkup:PickupStatusMessage>
<pkup:BillingCode>01</pkup:BillingCode>
<pkup:ContactName>Shipping Mgr.</pkup:ContactName>
<pkup:ReferenceNumber>OnCallNextDayAir</pkup:ReferenceNumber>
</pkup:PendingStatus>
</pkup:PickupPendingStatusResponse>
</soapenv:Body>
1.
成功
01
20141006
2929AONCALL
001
发货时收到
01
航运经理。
OnCallNextDayAir
我需要获取PickupPendingStatusResponse->Response->ResponseStatus->Description
我还希望将
pkup:PendingStatus
放入一个数组
,并能够获取它的每个子值。我使用DOMDocument类来获取节点
$doc = new DOMDocument();
$doc->loadXML($upsResponse);
$PRN = $doc->getElementsByTagName('PRN')->item(0)->nodeValue;
$success = $doc->getElementsByTagName('Description')->item(0)->nodeValue;
您当前如何获取响应?考虑SOAPCclipse扩展以避免XML解析。否则,请看SimpleXML,我将使用客户机获取响应$c=新的SoapClient($wsdl)$response=$client->getRates($params),那么我认为您的值位于
$response->ResponseStatus->Description
我将xml文档作为字符串从$client->getRates($params)返回。通常会返回一个对象,但这次不是因为某些原因,SoapClient对于文档文字样式来说有点糟糕。再说一次,文档文字是非常糟糕的,而SOAP通常是一团糟。大多数人将nusoap用于繁琐的wsdl,您可能希望将其作为真正的解决方案进行探索