简体   繁体   中英

With Xpath, find the leafiest table node that contains an input box with id=“userid”

I've tried a couple of different variations, but I can't seem to get this right. Given html like:

<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>

I want to find the inner table.

I've tried like //table/*/input[@id='foo'] but I don't get the right things - doesn't anyone have a quick fix for me? :-)

Thanks so much!

其他方法:

//table[not(.//table)][.//input[@id='foo']]

未经测试:

//input[@id='foo']/ancestor::table[1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM