简体   繁体   中英

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. 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. 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 . So in your case:

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

should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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