检查前一个兄弟是否是标题元素

时间:2013-03-14 11:06:18

标签: xpath

我需要查看图中最接近的前面元素是否是标题元素。我的XML结构如下所示:

<section>
<title>Something</title>
<figure><graphic></graphic></figure>
<figure><graphic></graphic></figure>
<p>Some text</p>
</section>

1 个答案:

答案 0 :(得分:0)

取出前面的第一个兄弟并确认它是标题:

//figure[preceding-sibling::*[1][self::title]]
相关问题