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
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).
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