【发布时间】:2010-07-01 06:22:46
【问题描述】:
这个问题可能有点具体,但我正在编写的测试程序使用 XPath 在 HTML 中查找我需要的数据。这段 HTML(在此处找到)是我试图解析的内容。
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="textSm" align="right">1. </td> <!-- Location of the number is here -->
<td align="left" nowrap>
<a href="/stats/individual_stats_player.jsp?c_id=sf&playerID=467055" class="textSm">P Sandoval</a> <!-- Player location is here of the number is here -->
</td>
</tr>
</table>
我的目标是通过使用与他对应的数字来找到他的名字。这需要我通过“td class="textSm" align="right">1. </td>”中包含的特定文本找到一个节点,然后找到该节点的兄弟节点“<td align="left" nowrap>”,然后找到该兄弟节点的子节点“<a href="/stats/individual_stats_player.jsp?c_id=sf&playerID=467055" class="textSm">P Sandoval</a>”以获得所需的结果。我想知道我可以使用什么样的查询来找到这个。非常感谢任何帮助。
【问题讨论】:
-
好问题 (+1)。请参阅我对选择所需节点的单个 XPath 表达式的回答。
标签: objective-c xpath hpple