<分区>
关于如何解析此 SOAP 响应并获取 report_type
的 name
值的任何建议?注意有两个名称实例;一个在 report_type
下,另一个在 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)
它返回两个名称(原始漏洞和 HIGH)。
我知道我错过了一些愚蠢的东西。你能帮忙吗?提前致谢!