2014-09-12 62 views
0

對於下面的HTML內容,有人可以幫我提取價格(Price2),它緊跟在節點標籤後面並且其屬性checked =「true」。 樣本HTML內容:Xpath - 需要幫助來提取一個值

<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> 
+0

什麼價值或'$ 8.99'? – har07 2014-09-12 11:55:31

+0

$ price2 .. $ Price2 – Avinash 2014-09-12 11:57:16

回答

2

我相信有很多不同的XPath做同樣的,一個例子:

要提取準確,`$ Price2`
//tr[ 
     td//input[@checked='true'] 
    ] 
/td[@data-price]