xpath: extract data from a node
-
17-04-2021 - |
Question
I am trying to extra some data from a webpage. the structure of the webpage is as below
<li id="yui_3_4_1_1_1326860702769_9706">
<span id="yui_3_4_1_1_1326860702769_9705">Sales rank: </span>
2
</li>
http://www.barnesandnoble.com/w/enders-game-orson-scott-card/1100353963?ean=9781429963930
I need to extract value "2" from above and identifier has to be "Sales rank"
Thanks for all the help.
Solution
try this:
//descendant::*[@class='product-details box']/ul/li[span='Sales rank: ']/text()
OTHER TIPS
You can try using:
//div[@class="product-details"]/ul/li[9]
Not tested though.
Use:
//li[@id='yui_3_4_1_1_1326860702769_9706']
/span[. = 'Sales rank: ']
/following-sibling::text()[1]
This selects the first following-sibling text node of any span
element with string value 'Sales rank: '
, that is a child of any li
element whose id
attribute has the value of 'yui_3_4_1_1_1326860702769_9706'
.
try this, if any question, please let me know
`//li[@id]/*[contains(text(), 'Sales rank')]/following-sibling::node()[1]`
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow