[英]Xpath - need help in extracting a value
對於下面的HTML內容,有人可以幫我提取價格(Price2),該價格緊接在節點標簽之后,並且其屬性選中了=“ true”。 示例HTML內容:
<tbody>
<tr>
<td>
<label class="left">
<input type="radio" data-max-per-order="12" data-out-of-stock="0" data-purchasable="1" data-product-id="29391" data-product-option-id="24501" name="type" class="product-option" id="product_option_radio_for-24501" />3 doses</label>
</td>
<td id="per_pound_for_24501" class="right">
<span class="competitor">
$10.65
</span>
</td>
<td class="ships-free"> </td>
<td data-price="price1" id="price_for_24501" class="right">$Price1</td>
</tr>
<tr>
<td>
<label class="left">
<input type="radio" data-max-per-order="12" data-out-of-stock="0" data-purchasable="1" data-product-id="29391" data-product-option-id="24688" name="type" class="product-option" id="product_option_radio_for-24688" checked="true" />Some Text</label>
</td>
<td id="per_pound_for_24688" class="right">
<span class="competitor">
$8.99
</span>
</td>
<td class="ships-free"> <div>SHIPS <br /> FREE!</div></td>
<td data-price="Price2" id="price_for_24688" class="right">$Price2</td>
</tr>
</tbody>
我相信有很多不同的XPath可以做相同的事,例如:
//tr[
td//input[@checked='true']
]
/td[@data-price]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.