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