2012-09-25 85 views
0

我想選擇其祖先是TD與輸入標籤作爲子節點的節點的文本:選擇下面的兄弟文本,其祖先節點包含特定的子節點

輸入是:

<tr> 
    <td width="1"><input type="checkbox" name="marketCodes" value="AE01" onclick="facetCheckboxClicked(this)"></td> 
    <td style="padding-left:5px;padding-right:5px;">Defense &amp; Security&nbsp;(1028)</td> 
    <td width="1"><input type="checkbox" name="marketCodes" value="AE02" onclick="facetCheckboxClicked(this)"></td> 
    <td style="padding-left:5px;padding-right:5px;">Geotechnologies (96)</td> 
    <td style="padding-left:5px;padding-right:5px;">Aircraft Products & Services (594)</td> 
</tr> 

預期輸出是:

Defense &amp; Security&nbsp;(1028) 
Geotechnologies (96) 

回答

1

如何:

//td[preceding-sibling::td[1]/input]/text() 
相關問題