Does XPath substring work in the Firefox web inspector/console?

31 Views Asked by At

This Xpath returns a percentage (e.g, 16%):

//div/div/div[@class='underlay']/strong

I want to extract just the digits so I tried substring

substring (//div/div/div[@class='underlay']/strong, 1, 2)

but it just returns an error message.

Is this supposed to work?

According to the documentation on the link above the syntax is substring(string, start, length) and it is supported by Gecko.

Are there any other way to just get the digits (16)?

Thank you.


Update: I used it in the web inspector's search field as well as in the console using $x("//*")

1

There are 1 best solutions below

0
Conal Tuohy On

I just opened Firefox's inspector panel on this very page and evaluated the following in the console:

document.evaluate("substring(//div[@itemprop='text']/p[1], 39, 2)", document).stringValue

The result was the string "16". So I think we can say that it should definitely work.