Search code examples
htmlxmlxpathwebharvest

XPath for text after a div?


How could I extract the number "-105" with XPath 1.0/2.0?

<td class="alignRight bookColumn" rel="page1" style="">
  <div id="_Div_Line_5_523714_901_3_119">-115</div>
  <div id="_Div_Line_5_523714_902_3_119">   
    <div class="oddsAlignMiddleOne">9.0</div>                        
    -105
  </div>
</td>

I tried with:

/td/div[2]/text()

Solution

  • To select "-105", use the following-sibling axis:

    normalize-space(/td/div[2]/div/following-sibling::text())