所有,如何鑽到SOAP命名空間使用SimpleXML和PHP
我試圖訪問元素EBL:RequesterCredentials在SOAP響應,但其至今沒有成功。我正在使用PHP SimpleXML。至少對我來說是註冊EBL命名空間中的問題 - 所有我的迴應得到的是這樣的:
的xmlns =」金塔:易趣:蜜蜂:eBLBaseComponents」
我嘗試這樣做:
$r = $xml->registerXPathNamespace("ebl","urn:ebay:apis:eBLBaseComponents");
foreach($xml->xpath('ebl:RequesterCredentials') as $e){
$sig = (string) $e->NotificationSignature;
}
元素被嵌套這樣:
soapenv:信封 - > soapenv:標題 - > EBL:RequesterCredentials - > EBL:NotificationSignature
< soapenv:Envelope xmlns:soapenv =「http://schemas.xmlsoap.org/soap/envelope/」xmlns:xsd =「http://www.w3.org/2001/XMLSchema」xmlns:xsi =「http: //www.w3.org/2001/XMLSchema-instance 「> < soapenv:擡頭> < EBL:RequesterCredentials的xmlns:ns的= 」甕:易趣:的API:eBLBaseComponents「 的xmlns:EBL =」 甕:易趣:的API: eBLBaseComponents」 soapenv:mustUnderstand屬性= 「0」 > < EBL:NotificationSignature的xmlns:EBL = 「甕:易趣:的API:eBLBaseComponents」 > 9hJXr9QTtck33I/4wg135A == </EBL:NotificationSignature > </EBL:RequesterCredentials > </soapenv:標題> < soapenv:車身> < GetMemberMessagesResponse的xmlns = 「甕:易趣:的API:eBLBaseComponents」 > <消息> FOO < /消息> <時間戳> 2007-09-14T17:07:41.984Z < /時間戳> </GetMemberMessagesResponse > </soapenv:身體> </soapenv:信封>
有關如何訪問此元素的任何想法?
那你嘗試至今 – Wesley
$ H = $ XML的>的XPath( '/ soapenv:頁眉/ EBL:RequesterCredentials'); – Slinky