3
任何有關如何解析此SOAP響應並獲得report_type
的值name
的建議?注意有兩個名字的例子;一個在report_type
下,另一個在severity
下。使用PHP中的名稱空間解析SOAP響應
這裏是SOAP響應
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:getIRResponse xmlns:ns1="http://ws.icontent.idefense.com/V3/2">
<ns1:return xsi:type="ns1:IRResponse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:report_type>
<ns1:id>0</ns1:id>
<ns1:name>Original Vulnerability</ns1:name>
</ns1:report_type>
<ns1:severity>
<ns1:id>0</ns1:id>
<ns1:name>HIGH</ns1:name>
</ns1:severity>
</ns:return>
</ns1:getIRResponse>
</soapenv:Body>
</soapenv:Envelope>
這裏是我使用的PHP代碼:
<?php
$xml = simplexml_load_string($response);
$xml->registerXPathNamespace('ns1', 'http://ws.icontent.idefense.com/V3/2');
foreach ($xml->xpath('//ns1:report_type/name') as $item)
{
echo 'Name: '.$item,'<br>';
}
?>
的PHP代碼沒有任何迴音。當我使用($xml->xpath('//ns1:name') as $item)
時,它返回兩個名稱(原始漏洞和高)。
我知道我錯過了一些愚蠢的東西。你能幫忙嗎?先謝謝你!
請問爲什麼需要首先解析XML?您是否未使用內置的SOAP客戶端並通過其他方式獲取此數據? – Scuzzy