Does Chrome use XPath 2.0?

前端 未结 2 1998
不知归路
不知归路 2020-12-05 07:42

I was under impression that all latest browsers are with XPath 2 now. When I use lower-case() and uppser-case() (functions introduced in version 2)

相关标签:
2条回答
  • 2020-12-05 08:12

    Google Chrome (or Chromium) still uses libxml2 thus is limited to XPath 1.0. Cf. this Readme from the source.

    0 讨论(0)
  • 2020-12-05 08:15

    No, Chrome uses XPath 1.0.

    You can simplify your XPath expression to just a v2.0 function to see this:

    $x("lower-case('ABC')")
    SyntaxError: Failed to execute 'evaluate' on 'Document': The string 'lower-case('ABC')' is not a valid XPath expression.
    

    Trying any other XPath 2.0 function such as current-date() will yield a similar error.

    There is no built-in way of definitively determining the version of an XPath implementation other than by such probes.

    XSLT, on the other hand, has system-property('xsl:version') for determining version 1.0 versus 2.0.

    0 讨论(0)
提交回复
热议问题