mardi 13 février 2018

XPath return NULL node list when query

Somehow XPath behaves very oddly:

I enter this into the query () method and that I see that not deeply nested tags of the type (/ html / head / title) it finds and returns the content , but deep

like (// * [@ id = "ext-gen154"] / div [1] / table / tbody / tr [1] / td [8] / div) it returns NUll NodeList object. Anybody please help me i can`t solve this problem in 4 days.

This is my script:

<?php

$html = file_get_contents('https://etp.gpb.ru/#com/procedure/index');

$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;


$dom->loadHtml($html);
$xPath = new DOMXPath($dom);


echo $node = $xPath->query('//*[@id="ext-gen154"]/div[1]/table/tbody/tr[1]/td[8]/div')
     ->length;


if ($node === NULL){
    echo "Node is NULL <br>";
}

 var_dump($node);

?>




Aucun commentaire:

Enregistrer un commentaire