Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Xpath不';t return“;“生活”;节点列表_Php_Xpath_Domdocument - Fatal编程技术网

PHP Xpath不';t return“;“生活”;节点列表

PHP Xpath不';t return“;“生活”;节点列表,php,xpath,domdocument,Php,Xpath,Domdocument,有时,似乎返回的域名列表不是活的 当使用类似子节点的访问时,它是活动的 $children=$doc->getElementsByTagName('body')->item(0)->childNodes; echo $children->length; //7 $children->item(0)->parentNode->removeChild($children->item(0)); echo $children->leng

有时,似乎返回的域名列表不是活的

当使用类似子节点的访问时,它是活动的

 $children=$doc->getElementsByTagName('body')->item(0)->childNodes;
 echo $children->length;  //7
 $children->item(0)->parentNode->removeChild($children->item(0));

  echo $children->length;  //6! list is live! 
但其他时候,这个名单是不活的

$xpath=new DOMXPath($doc);
$nodes=$xpath->query("//p");

echo $nodes->length; // 7
$nodes->item(0)->parentNode->removeChild($nodes->item(0));
echo $nodes->length; // still 7? Not live. 
XPath似乎是罪魁祸首。但如果域名列表不是活动的,为什么还要返回它呢?为什么不在那个点上创建一个数组呢