6

I was looking at https://en.wikipedia.org/wiki/XPath_2.0 and I was surprise to find out that modern browser engines do not support XPath 2.0. I have successfully used XPath 2.0 function such as substring-after and matches in Chrome without much issue but according to the official docs this should not be supported as it is not part of XPath 1.0.

Is the Compatible browser engine list outdated, or am I missing something? Anyone has a historical context why such an old spec released on 2007 still not supported?

kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

3

You are correct that web browsers do not support XPath 2.0, but you are mistaken about two observations you made:

  • substring-after() only requires XPath 1.0.
  • matches() is indeed an XPath 2.0+ function, but it is not supported in any web browser's XPath implementation.

You can assess the likelihood of support for XPath 2.0 by reading this recent (2020-10-13) thread in whatwg / dom Github issues:

TLDR: Don't hold your breath.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240