排除,包括xPath

时间:2015-09-28 09:57:07

标签: xpath

我试图在现有的xpath中排除并包含跟踪xpat​​h,不太确定我该怎么做

//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'); 

1 个答案:

答案 0 :(得分:2)

您可以使用管道确保包含结果:

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

我无法理解您尝试排除的内容最终会在结果中出现。

相关问题