Html 如何在一个查询中使用xpath在相似但略有不同的节点中获取值?
我想创建xpath查询,从link1和Link2获取url,并要求不更改结果中的顺序Html 如何在一个查询中使用xpath在相似但略有不同的节点中获取值?,html,xpath,Html,Xpath,我想创建xpath查询,从link1和Link2获取url,并要求不更改结果中的顺序 First situation <div id="id"> <span class="class"> <a href=http://whatever.url>link 1</a> </span> </div> Second Situation <div id="id"> <span
First situation
<div id="id">
<span class="class">
<a href=http://whatever.url>link 1</a>
</span>
</div>
Second Situation
<div id="id">
<span class="class anotherclass">
<h5>
<a href=http://whatever.url>link 2</a>
</h5>
</span>
</div>
(...Above situation can happen more times on site in any order...)
但是我不能让它工作。像这样,在“变量”层次结构上使用//怎么样
div[@id='id']/span[@class]//a[@href]
div[@id='id']/span[@class]//a[@href]