如何选择2个兄弟节点Xpath之间的所有节点?

时间:2015-03-15 17:11:45

标签: html xpath

HTML:

<div class="article_content">
     <div><img src="....jpg" alt="...">
          <span class="caption">Source</span>
     </div>
<p>Sub Title Text</p>               
<p>Yes</p>                          
<p>Yes</p>              
<p>Yes</p>      
<p>Yes</p>          
<p>Yes</p>                      
<p><strong>No</strong> </p> 
<hr>
<p class="additional">No</p>
<ul class="menu_list">
   <li><a href="...">No</a></li>
   <li><a href="...">No</a></li>
</ul>

我想把所有标记为是的。

介于:

之间
article[@class="article-body"]/div[@class="ctx_content"]/div[@id="article_container"]/div[@class="article_column"]/p[1]

//article[@class="article-body"]/div[@class="ctx_content"]/div[@id="article_container"]/div[@class="article_column"]/p/strong

1 个答案:

答案 0 :(得分:1)

使用following-siblingposition()的组合检查:

//article[@class="article-body"]/div[@class="ctx_content"]/div[@id="article_container"]/div[@class="article_column"]/p[following-sibling::p/strong and position() > 1]