我得到了以下HTML表格,我需要找到包含tr
span
的{{1}}的ID,其值为Action2
和Server1
以及Tag2
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="table-layout:fixed;" id="rtTkFrm:recTkTabId" class="dr-table rich-table ">
<colgroup span="8"></colgroup>
<tbody id="rtTkFrm:recTkTabId:tb">
<tr class="dr-subtable-row rich-subtable-row dr-subtable-firstrow rich-subtable-firstrow 0">
<td width="2%" style="padding-left:17px;" id="rtTkFrm:recTkTabId:0:innertable:0:j_id31" class="dr-subtable-cell rich-subtable-cell ">
<label class="CollapseRow" onclick="noOfRows(this);" id="rtTkFrm:recTkTabId:0:innertable:0:expand"></label>
</td>
<td style="width:20%" id="rtTkFrm:recTkTabId:0:innertable:0:TkDesc" class="dr-subtable-cell rich-subtable-cell adjacent TkDescC">
<span title="Action1" class="adjacentSpan" id="rtTkFrm:recTkTabId:0:innertable:0:cell-">Action1</span>
</td>
<td style="width:22%" id="rtTkFrm:recTkTabId:0:innertable:0:tgt" class="dr-subtable-cell rich-subtable-cell adjacent tgtC">
<span title="Server1" class="adjacentSpan">Sever1</span>
</td>
<td style="width:16%" id="rtTkFrm:recTkTabId:0:innertable:0:tgtDep" class="dr-subtable-cell rich-subtable-cell adjacent tgtDepC">
<span title="Tag1" class="adjacentSpan">Tag1</span>
</td>
</tr>
<tr class="dr-subtable-row rich-subtable-row dr-subtable-firstrow rich-subtable-firstrow 0">
<td width="2%" style="padding-left:17px;" id="rtTkFrm:recTkTabId:0:innertable:0:j_id31" class="dr-subtable-cell rich-subtable-cell ">
<label class="CollapseRow" onclick="noOfRows(this);" id="rtTkFrm:recTkTabId:0:innertable:0:expand"></label>
</td>
<td style="width:20%" id="rtTkFrm:recTkTabId:0:innertable:0:TkDesc" class="dr-subtable-cell rich-subtable-cell adjacent TkDescC">
<span title="Action2" class="adjacentSpan" id="rtTkFrm:recTkTabId:0:innertable:0:cell-">Action2</span>
</td>
<td style="width:22%" id="rtTkFrm:recTkTabId:0:innertable:0:tgt" class="dr-subtable-cell rich-subtable-cell adjacent tgtC">
<span title="Server1" class="adjacentSpan">Server1</span>
</td>
<td style="width:16%" id="rtTkFrm:recTkTabId:0:innertable:0:tgtDep" class="dr-subtable-cell rich-subtable-cell adjacent tgtDepC">
<span title="Tag2" class="adjacentSpan">Tag2</span>
</td>
</tr>
<tr class="dr-subtable-row rich-subtable-row dr-subtable-firstrow rich-subtable-firstrow 0">
<td width="2%" style="padding-left:17px;" id="rtTkFrm:recTkTabId:0:innertable:0:j_id31" class="dr-subtable-cell rich-subtable-cell ">
<label class="CollapseRow" onclick="noOfRows(this);" id="rtTkFrm:recTkTabId:0:innertable:0:expand"></label>
</td>
<td style="width:20%" id="rtTkFrm:recTkTabId:0:innertable:0:TkDesc" class="dr-subtable-cell rich-subtable-cell adjacent TkDescC">
<span title="Action1" class="adjacentSpan" id="rtTkFrm:recTkTabId:0:innertable:0:cell-">Action1</span>
</td>
<td style="width:22%" id="rtTkFrm:recTkTabId:0:innertable:0:tgt" class="dr-subtable-cell rich-subtable-cell adjacent tgtC">
<span title="Server2" class="adjacentSpan">Server2</span>
</td>
<td style="width:16%" id="rtTkFrm:recTkTabId:0:innertable:0:tgtDep" class="dr-subtable-cell rich-subtable-cell adjacent tgtDepC">
<span title="Tag2" class="adjacentSpan">Tag2</span>
</td>
</tr>
</tbody>
</table>
我尝试了以下但是没有按预期工作
//id('recentTaskFrm:recTaskTabId')/tbody/tr/td[descendant::span[@title='Action1' and @title='Server2' and @title='Tag2']]/@id
答案 0 :(得分:0)
试试这个://id('recentTaskFrm:recTaskTabId')/tbody/tr/td[descendant::span[@title='Action1'] and descendant::span[@title='Server2'] and descendant::span[@title='Tag2']]/@id
答案 1 :(得分:0)
有两个问题:
@id
属性(rtTkFrm:recTkTabId
,而不是recentTaskFrm:recTaskTabId
)。@id
属性,而不是行。尝试此查询:
//table[@id='rtTkFrm:recTkTabId']/tbody/tr[
td//span[@title="Action2"]
and td//span[@title="Server1"]
and td//span[@title="Tag2"]
]