xpathsiblingsxpath-2.0nextsibling

XPath. How to get element with next sibling of concrete type?


I have following elements:

<div>
  <table/>
  <div/>
  <table/>
  <div/>
  <table/> <!--I need to get only this one-->
  <table/>
  <div/>
</div>

So how to get //div/table with next element table?


Solution

  • Use //div/table[following-sibling::*[1][self::table]].