查看文档,目标是从第一个表中的第二行中选择第二个单元格。
我创建了以下表达式:
//row/td[2]/text()[td[@class="identifier"]/span[text()="identifier"]]
但它不返回任何行。不幸的是,我看不出有什么问题。
对我来说,看起来还不错。表达式应该:
select the text
in the second cell
in any row
where
the text of a span equals to "identifier"
and the span is located in cell with a "identifier" class
如果您能指出我做错了什么,我将不胜感激。
示例 XML 文档:
<?xml version="1.0"?>
<html>
<table class="first">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td class="identifier">
<span>identifier</span>
</td>
<td>
foo
<span>ignore</span>
bar
</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
</tr>
</table>
<table class="second">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td class="identifier">
<span>not an identifier</span>
</td>
<td>
not a target
</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
</tr>
</table>
</html>