通过使用注释节点作为限制器来选择有限的节点范围

时间:2013-06-07 07:58:27

标签: xpath

我试图在两个评论之间选择节点

<ul>
  <!-- fromHere -->
  <option>a</option>
  <option>a</option>
  <option>a</option>
  <option>a</option>
  <option>a</option>
  <!-- toHere -->
  <option>a</option>
  <option>a</option>
  <option>a</option>
  <option>a</option>
</ul>



$x("//comment()[.=' fromHere ']/following-sibling::* | //comment()[.=' toHere ']/preceding-sibling::*")

有没有进行AND选择?

1 个答案:

答案 0 :(得分:0)

试试这个xpath

//option[preceding-sibling::comment()=" fromHere " and following-sibling::comment()=" toHere "]