2014-09-12 63 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]