我有下一张桌子:
<table border="1">
<tbody>
<tr>
<th>Created By</th>
<th>Modified</th>
<th>Status</th>
</tr>
<tr>
<td>Mr. John</td>
<td>COMPLETE</td>
<td>PENDING</td>
</tr>
<tr>
<td>Mr. Lorem</td>
<td>COMPLETE</td>
<td>COMPLETE</td>
</tr>
</tbody>
</table>
COMPLETE
TH?Status
状态的道明
COMPLETE
TH?Status
的TR
醇>
答案 0 :(得分:1)
如何在状态TH下选择具有COMPLETE状态的TD?
//td[
normalize-space() = 'COMPLETE' and
count(preceding-sibling::td) = count(
ancestor::tbody/tr/th[normalize-space() = 'Status']/preceding-sibling::th
)
]
如何在状态TH下选择状态为完全状态的TR?
我将此作为练习。
答案 1 :(得分:0)
将您的表格作为:
Created | Modified | Status
----------------------------
Mr.John COMPLETE PENDING
Mr.Lorem COMPLETE COMPLETE
并从您的问题1.和2.
你想要1://table/tbody/tr/td[3][.='COMPLETE']
for 2://table/tbody/tr/td[3][.='COMPLETE']/parent::tr