import.io - XPath to select 1 element if one of two exists -


i want select 1 element if 1 out of 2 exist while using 2 pages

1st page (price discount)

<div class="price">   <span class="originalretailprice">$2,990.00</span>   </div> </div> <div class="price">       <span class="saleprice">$1,794.00</span> </div> 

or 2nd page (only 1 price)

<div class="price">   $298.00 </div> 

i have used //span[@class="originalretailprice"] | (//div[@class="priceblock"])[1] price twice

what want select first price when it's class="originalretailprice" or when it's //div[@class="price"]/text()[1]

so want make selection work on both pages

use // texts @ level inside <div class="price">:

//div[@class="price"][1]//text() 

result:

text='' text='$2,990.00' text='' 

and filter empty texts with: text()[normalize-space() , not(ancestor::a | ancestor::script | ancestor::style)]

//div[@class="price"][1]//text()[normalize-space() , not(ancestor::a | ancestor::script | ancestor::style)] 

result 1st page:

text='$2,990.00' 

result 2nd page:

text='$298.00' 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -