xml – 用于定位具有解析HTML表的特定文本的单元格的XPath

希望有人可以迅速指出我在XPath困难的正确方向.

目前我已经到了我在HTML源代码中识别我需要的正确表格的那一点,但后来我只需要处理在DOM中某处有文本“Chapter”的行.

我的最后一次尝试是这样做:

// get the correct table
HtmlTable table = page.getFirstByXPath("//table[2]");

// now the failing bit....
def rows = table.getByXPath("*/td[contains(text(),'Chapter')]")

我认为上面的xpath代表,让我所有具有后续子元素’td’的元素在其dom中的某个地方包含文本’Chapter’

我的源代码中匹配行的示例如下:

<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>&nbsp;</td>
</tr>

任何帮助/指针非常感谢.

谢谢,

使用此XPath:
//td[contains(.,'Chapter')]

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念