,我有以下的HTML我一起工作:(它的一大塊這裏)查找XPath的特定元素的位置確認條件後
<table class="detailTable">
<tbody>
<tr>
<td class="detailTitle" align="top">
<h3>Credit Limit:</h3>
<h3>Current Balance:</h3>
<h3>Pending Balance:</h3>
<h3>Available Credit:</h3>
</td>
<td align="top">
<p>$677.77</p>
<p>$7.77</p>
<p>$7.77</p>
<p>$677.77</p>
</td>
<td class="detailTitle">
<h3>Last Statement Date:</h3>
<h4>Payment Address</h4>
</td>
<td>
<p> 05/19/2015 </p>
<p class="attribution">
</td>
</tr>
</tbody>
</table>
我需要首先檢查是否「Statement Date
」的存在,然後找到它的位置。然後獲取相應<p>
標記中的值。我需要使用XPath來執行此操作。有什麼建議麼?
到目前爲止,我嘗試使用//table[@class='detailTable'][1]//td[2]//p[position(td[contains(.,'Statement Date')])]
,但它不起作用。
你知道它不在你顯示的html中嗎? –
對不起,這是一個錯誤@PadraicCunningham ..更正 – DT7
你使用什麼語言? –