[Solved] XML DOMDocument PHP – Get node where attribute value [closed]


Try this

    <?php
    $slideids = array();
    $get_id = 2; 
    $xml = new DOMDocument();
    $xml->load('test.xml'); // path of your XML file ,make sure path is correct
    $xpd = new DOMXPath($xml);
    false&&$result_data = new DOMElement(); //this is for my IDE to have intellysense
    $result = $xpd->query("//row[@id=".$get_id."]/*");  // change the table naem here
    foreach($result as $result_data){
        $key = $result_data->nodeName;
        $values = $result_data->nodeValue;
        $slideids[$key] = $values;
    }

    echo '<pre/>';
    print_r($slideids);
?>

Sort of reference Manual for XPath Queries/expressions

2

solved XML DOMDocument PHP – Get node where attribute value [closed]