この SOAP 応答を解析して の値を取得する方法に関する推奨事項はname
ありreport_type
ますか? name には 2 つのインスタンスがあることに注意してください。1つは下report_type
に、もう1つは下にseverity
。
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)
と、両方の名前 (元の脆弱性と高) が返されます。
私は愚かな何かが欠けていることを知っています。助けていただけますか?前もって感謝します!