Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.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
排除,包括xPath_Xpath - Fatal编程技术网

排除,包括xPath

排除,包括xPath,xpath,Xpath,我试图在现有的xpath中排除并包含以下xpath,但不太确定如何做到这一点 //exclude -> //*[@id="ires"]/ol/li[6]/div/a[1]/img //include -> //*[@id="ires"]/ol/li[4]/table/tbody/tr[1]/td/h3/a/@href 添加到下面的xpath $nodes = $xpath->evaluate('//*[@id="ires"]/ol/li['.$k.']/h3/a/@href

我试图在现有的xpath中排除并包含以下xpath,但不太确定如何做到这一点

//exclude  -> //*[@id="ires"]/ol/li[6]/div/a[1]/img
//include -> //*[@id="ires"]/ol/li[4]/table/tbody/tr[1]/td/h3/a/@href
添加到下面的xpath

$nodes = $xpath->evaluate('//*[@id="ires"]/ol/li['.$k.']/h3/a/@href'); 

通过使用管道,您当然可以包括结果:

//*[@id="ires"]/ol/li['.$k.']/h3/a/@href | //*[@id="ires"]/ol/li[4]/table/tbody/tr[1]/td/h3/a/@href

我无法理解您试图排除的内容如何在一开始就出现在结果中。

您能展示一个DOM示例以及您想要获得的内容吗。使用$nodes=$xpath->evaluate('/*[@id=“ires”]/ol/li['.$k.]/h3/a/@href');我得到了正确的结果,只是不知道如何排除和包括其他XPath,如果我可以使用类,没有问题,但我不能。