我尝试了几种不同的变体,但我似乎无法做到这一点。鉴于html:
<html>
<body>
<table>
<tr>
<td>
<table> <-- I want this table
<tr>
<td><input type="text" id="foo"/></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
我想找到内表。
我尝试过// table / * / input [@ id ='foo']但是我找不到正确的东西 - 没有人能快速解决这个问题吗? : - )
非常感谢!
答案 0 :(得分:3)
其他方法:
//table[not(.//table)][.//input[@id='foo']]
答案 1 :(得分:2)
未测试:
//input[@id='foo']/ancestor::table[1]