简体   繁体   English

以下兄弟的 xpath 存储为 header 和值

[英]xpath of following sibling which is stored as header and value

I am trying to extract the flavour name - Fizzy Drink which has a label Flavour.我正在尝试提取风味名称 - 具有 label 风味的 Fizzy Drink。 so far i tried Xpath - //span[contains(@class, "a-size-base a-text-bold") and text()="Flavour"] which gives me the flavour, I want to extract the value - Fizzy Drink using next sibling.到目前为止,我尝试了 Xpath - //span[contains(@class, "a-size-base a-text-bold") 和 text()="Flavour"] 这给了我味道,我想提取价值 -使用下一个兄弟姐妹的汽水。 Please help请帮忙

<tr class="a-spacing-small">
<td class="a-span3">
<span class="a-size-base a-text-bold">Flavour</span>
</td>
<td class="a-span9">
<span class="a-size-base">Fizzy Drink</span>
</td>
</tr>

In xpath, "next sibling" is represented by the following-sibling axis .在 xpath 中,“下一个兄弟”由以下兄弟轴表示。 So in your case:所以在你的情况下:

//td[span[.="Flavour"]]/following-sibling::td//span/text()

should do it.应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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