0

I want to select a button which contains a number greater than 1, so i have written the following:

//*mobile-list-outcome[1]/div/div[2][number(.) > 1]

My issue is that i want to avoid the first element, because it is irrelevant, my solution was that i tried putting index [1] at the end:

 //*mobile-list-outcome[1]/div/div[2][number(.) > 1][1]

but all it did was that it decreased found elements to 0, any ideas ?

PC: I also tried putting and between the two conditions and it didn't do anything at all

1 belowu
  • 1
  • 1
  • How about below xpath: `(//*mobile-list-outcome[1]/div/div[2][number(.) > 1])[position()>1]` . It will return all elements except first one – Kuldeep Kamune Jul 25 '20 at 15:57

1 Answers1

0

To skip the first element, you can use position() index. In your case :

//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[number(.)>1][position()>1]

or

//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[number(.)>1][not(position()=1)]

Note that the following expression should work without the number() function :

//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[.>1][position()>1]

Side note : you can use () to select the first element of the page which fulfill your conditions :

 (//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[.>1])[1]

EDIT : 3 options to test :

//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div[position()>1]/div[2]/text()[.>1]
(//*/sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[.>1])[position()>1]
//div[@class="sb-event-list__selection sb-event-list__selection--european"][position()>1]/div[contains(@class,"sb-event-list__selection__outcome-value")][.>1]
E.Wiest
  • 5,425
  • 2
  • 7
  • 12
  • Sorry, Xpath that i showcased is changed, but i used the method that u proposed (//* /sb-mobile-odds/div//sb-mobile-list-outcome[1]/div/div[2]/text()[number(.)>1])[1] it only showed one element, i want it to show all elements except the first one PC: the first value that i'm trying to get rid of is an integer , although other elements that i'm aiming to select some of them are integers aswell, dunno if its helpful – 1 belowu Jul 25 '20 at 15:18
  • -_-. Post has been edited. Should be OK now. I thought you wanted to keep only the first appearing element. Sorry for the confusion. If this doesn't work, please post relevant HTML code. – E.Wiest Jul 26 '20 at 00:52
  • This is just one div container for one of the elements: `
    1
    2.55
    `
    – 1 belowu Jul 27 '20 at 14:33
  • Post has been edited with 3 options to test. The position of the position predicate (`[position()>1]`) is important. And also hard to determine without seeing the full HTML code.;| – E.Wiest Jul 27 '20 at 16:38