doulangbizhan5160 2016-05-31 12:09 采纳率: 100%
浏览 42

使用PHP 5.6修补漏洞XML 2.0 NIST

I'm trying to parse the next xml which i attach. The problem is that i can't parse the next lines with PHP 5.6. I want to extract the attributes.

<vuln:vulnerable-configuration id="http://www.nist.gov/">
  <cpe-lang:logical-test operator="OR" negate="false">
    <cpe-lang:fact-ref name="cpe:/o:microsoft:windows_8:-"/>
    <cpe-lang:fact-ref name="cpe:/o:microsoft:windows_8.1:-"/>
    <cpe-lang:fact-ref name="cpe:/o:microsoft:windows_server_2012:-:gold"/>
    <cpe-lang:fact-ref name="cpe:/o:microsoft:windows_rt:-:gold"/>
    <cpe-lang:fact-ref name="cpe:/o:microsoft:windows_rt_8.1:-"/>
  </cpe-lang:logical-test>
</vuln:vulnerable-configuration>

I have used the next code but i cannot capture de cpe-lang field. Also i have tried using namespaces but i cannot get the children of something inside the vuln namespace.

[$source = file_get_contents('C:/xampp/htdocs/prueba/products1.xml');
$xml    = new SimpleXMLElement($source);
$entries = $xml->entry;
foreach ($entries as $entry) {
        $namespace = $entry->getNameSpaces(true);
        $tmp = $entry->children($namespace\['cpe-lang'\],false);
        print_r($tmp)
        $aux={'fact-ref'};
        $config\['fact-ref'\]= (string)$entry->children('vuln', TRUE)->config->children($aux, TRUE)->logical_test->{'fact-ref'};
        print_r($config);
}][1]

If i print the variable $tmp it says that the array is empty. When i print $config it says:

Warning: main(): Node no longer exists in C:\xampp\htdocs\prueba\probando.php on line 56
Notice: Trying to get property of non-object in C:\xampp\htdocs\prueba\probando.php on line 56
Array ( [fact-ref] => )

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大