从XPATH结果中排除节点

时间:2013-03-28 13:42:49

标签: xpath

我尝试从下面的div标签中提取每个text(),但是在a标签之间没有text()。

我用这个没有成功:

//div[@class="availability"]/*[not(self::a)]/text()

这是html

<div class="availability">
   Available. Delivered from UK <br><a href="test.com">Click for more</a>
</div>

<div class="availability">
   Available. Delivered from HK <br><a href="test.com">Click for more</a>
</div>

<div class="availability">
   Available. Delivered from USA <br><a href="test.com">Click for more</a>
</div>

<div class="availability">
   Available. Delivered from DE <br><a href="test.com">Click for more</a>
</div>

感谢您引导我走向正确的方向!

1 个答案:

答案 0 :(得分:1)

//div[@class="availability"]/text()