Hey
Hey

Reputation: 121

xpath how can I select elements that have a number inside text?

<span>Постов: 223 / Файлов: 10</span>
<span>Постов: 23 / Файлов: 0</span>
<span>Постов: 63 / Файлов: 6</span>

How can I select all spans containing number <99 after "Постов: "

I tried this

//span[contains(text(), "Постов: ") and number(substring(text(), 9, 3))<99]

Upvotes: 2

Views: 190

Answers (1)

Daniel Manta
Daniel Manta

Reputation: 6683

The number you want appears after "Постов: " and before " /". So you can use substring-after() and substring-before().

//span[substring-before(substring-after(text(),'Постов: '),' /') < 99]

Upvotes: 1

Related Questions