Hope someone out there can quickly point me in the right direction with my XPath difficulties.
Currently, I have come to the point that I am defining the correct table that I need in my source HTML file, but then I only need to process the lines with the text "Head" somewhere in the DOM.
My last attempt was to do this:
// get the correct table HtmlTable table = page.getFirstByXPath("//table[2]"); // now the failing bit.... def rows = table.getByXPath("*/td[contains(text(),'Chapter')]")
I thought that the xpath view above would represent, get all the elements that have the next child element 'td', which somewhere in its dom contains the text βChapterβ
An example of a suitable line from my source:
<tr valign="top"> <td nowrap="" align="Right"> <font face="Verdana"> <a href="index.cfm?a=1">Chapter 1</a> </font> </td> <td class="ChapterT"> <font face="Verdana">DEFINITIONS</font> </td> <td> </td> </tr>
Any help / pointers are greatly appreciated.
Thanks,
xml xpath groovy htmlunit
Dave
source share