I have this kind of DOM:
<a>abc</a>
<a>def</a>
<a>13456</a>
<a>gh564</a>
I want to get the element which contains only digits.
I could do it by getting all the elements and looping them to check if text() is digits, but I would prefer to find it directly with Xpath. Is it possible?
Use
//a[number() = number()], but that would work for floating point content like<a>3.14</a>too, so perhaps//a[matches(., '^[0-9]+$')]. Or the old, XPath 1,translatetest://a[not(translate(., '0123456789', ''))].