我的HTML
<table id="mainTable" border="1">
<tbody>
<tr>
<td align="center" colspan="14">State Wise Revenue of a Bank (all Figures are in INR and in Lacs)</td>
</tr>
<tr>
<td>State \ Month</td>
<td>
<a href="#" onclick="">November</a>
</td>
<td>
<a href="#" onclick="">December</a>
</td>
<td>
<a href="#" onclick="">January</a>
</td>
<td>
<a href="#" onclick="">February</a>
</td>
<td>
<a href="#" onclick="">March</a>
</td>
<td>
<a href="#" onclick="">April</a>
</td>
<td>
<a href="#" onclick="">May</a>
</td>
<td>
<a href="#" onclick="">June</a>
</td>
<td>
<a href="#" onclick="">July</a>
</td>
<td>
<a href="#" onclick="">August</a>
</td>
<td>
<a href="#" onclick="">September</a>
</td>
<td>
<a href="#" onclick="">October</a>
</td>
<td>
<a href="#" onclick="">Operation</a>
</td>
</tr>
<tr>
<td>Sikkim</td>
<td>
<div id="1_1" name="1">71481</div>
</td>
<td>
<div id="1_2" name="1">10413</div>
</td>
<td>
<div id="1_3" name="1">75560</div>
</td>
<td>
<div id="1_4" name="1">32333</div>
</td>
<td>
<div id="1_5" name="1">21008</div>
</td>
<td>
<div id="1_6" name="1">70787</div>
</td>
<td>
<div id="1_7" name="1">6758</div>
</td>
<td>
<div id="1_8" name="1">47243</div>
</td>
<td>
<div id="1_9" name="1">65985</div>
</td>
<td>
<div id="1_10" name="1">80545</div>
</td>
<td>
<div id="1_11" name="1">54327</div>
</td>
<td>
<div id="1_12" name="1">72603</div>
</td>
<td>
<a id="Edit_1" href="#" onclick="fnEditRevenue("1");">Edit</a>
|
<a id="Hide_1" href="#" onclick="fnHideRevenue(1);">Hide</a>
|
<a id="Show_1" href="#" style="visibility:hidden" onclick="fnShowRevenue(1);">Show</a>
</td>
</tr>
<tr>
<tr>
<td>Tripura</td>
<td>
<div>
<input id="3_1" type="text" value="4851" style="width:50px" name="U3">
<br>
<input type="button" value="Update" onclick="fnUpdateRevenue("3_1")" style="width:60px">
</div>
我想使用xpath在firepath中选择'tripura'及其兄弟文本框但是使用以下xpath我可以选择'tripura','textbox','update button'
//td[.='Tripura']/following-sibling::*/*
所以我的问题是如何避免选择“更新按钮”。有什么帮助吗?
答案 0 :(得分:1)
在xpath成功为我选择文本框,如果你想要的话:
//td[.='Tripura']/following-sibling::td/div/input[@type='text']
所选元素:(使用firepath)
<input id="3_1" type="text" name="U3" style="width:50px" value="4851"/>