DOM Level 3 XPath in Internet Explorer

前端 未结 2 1617
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 07:14

I just installed IE10 on my Windows 7, and I\'ve noticed that, even if I\'m glad that XMLs from AJAX requests are now compatible DOM documents, a rather basic function like

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

    Yes, there's still no XPath support in IE =/.

    For me, the most reliable way to use document.evaluate in every browser is, sadly, via a library.

    It's called Wicked Good XPath and it's a recent Google-authored rewrite of the old good JavaScript-XPath library. I've been using Wicked Good XPath since the release and have been really comfortable with it (well, not as much as with a native XPath support, but still).

    0 讨论(0)
  • 2020-12-08 08:03

    It's part of Microsoft Edge build 10240+: modern.ie:DOM Level 3 XPath

    The IE Dev Channel has a build you can use to preview it:

    • Internet Explorer Developer Channel for Windows 7 SP1

    • Internet Explorer Developer Channel for Windows 8.1

    It's using wicked-good-xpath internally:

    In order to support WGX without polluting a Web page’s context, we created a separate, isolated script engine dedicated to WGX. With a few modifications to WGX that provide entry points for invoking functions and accessing results, we marshal the data from the page to the isolated engine and evaluate expressions with WGX. With WGX enabled to handle native XPath queries, we see immediate gains from sites missing content in our new engine rendering the modern Web

    For now, MSDN has a migration guide which recommends the following:

    In general, try to migrate to native objects and APIs unless you need features like XPath/XSLT; this can be done by passing responseText to DOMParser, instead of using responseXML var:

    If MSXML APIs are still required, feature checks can be updated to verify the type of node received in order to select the correct API:

    References

    • Improving interoperability with DOM L3 XPath
    • Native XML object types and legacy websites
    • XMLHttpRequest responseXML in IE10 Release Preview
    • DOMParser and XMLSerializer in IE9 Beta
    • DOMParser and XMLSerializer Demo
    • How To Include Client-Side Script Functions in an XSL Document
    • Details for Document API - Microsoft Edge Development
    0 讨论(0)
提交回复
热议问题