繁体   English   中英

Xpath-提取值时需要帮助

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM