I have an XPATH query I am running in PHP against the following XML from CWE:
<Weaknesses>
<Weakness ID="211" Name="Test" Weakness_Abstraction="Base" Status="Incomplete">
<Description>
<Description_Summary>
The software performs an operation that triggers an external diagnostic or error message that is not directly generated by the software, such as an error generated by the programming language interpreter that the software uses. The error can contain sensitive system information.
</Description_Summary>
</Description>
</Weakness>
</Weaknesses>
I have written the following PHP with XPATH in order to target the content within the "Description_Summary" child node, however, it simply returns Array(). I have a $_GET which pulls the $searchString variable from the previous page, pointing to my specific attribute found within the "Weakness" node.
<?php
$searchString = $_GET["searchString"];
echo "<b>CWE Name: </b>" . $searchString . "</br>";
$xml = simplexml_load_file("cwe.xml");
$description = $xml->xpath('//Weakness[@Name="'. $searchString .'"]/Description/Description_Summary/text()');
echo "<pre>"; print_r($description); echo "</pre>";
?>
What it currently returns:
Array
(
[0] => SimpleXMLElement Object
(
)
)
What is wrong with my print statement or XPATH query? Thanks!