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 document.evaluate
is still not supported.
What's worse is that, since those XMLs are not the custom Microsoft IXMLDocument
objects, the nodes don't support selectNodes
and selectSingleNode
anymore. In the end, it seems that IE10 does not support DOM Level 3 XPath or MSXML Xpath.
Seriously, Microsoft? Is there something I'm missing?
Sure, I can use querySelector
and querySelectorAll
, but I don't want to lose quite a bit of backward compatibility.
Otherwise, one can still request a MSXML document using this line
try {xhr.responseType = "msxml-document";} catch(e) {}
as stated here, but I think it would be nice to deal with, at last, a standard DOM document in IE too.
So, is there a way to use XPath in IE10 with standard DOM documents?
UPDATE 26/7/2013 IE11 isn't stable yet, but it still doesn't support document.evaluate
. If it won't support it in the stable release, I doubt it will ever support it. Needless to say this is ridicolous.
I get that you can use querySelector
/All
in DOM nodes, but it's not supported in IE9 and lower, which are still quite commonly used, and anyway XPath is more powerful than selectors.
Fortunately (if you can say that), you can still set xhr.responseType = "msxml-document"
. For a moment I feared you couldn't do that anymore...
UPDATE 23/11/2013 IE11 is stable now but, sadly, it doesn't support document.evaluate
. As heavy-weight XML documents are used less and less in web applications in favor of JSON or other light notation formats, this is becoming less of a problem, but still.
Setting the responseType
property still provides legacy XML documents, so nothing is lost I guess. I don't know if that will stay true for IE12, though.
UPDATE 15/8/2015 Sounds ridiculous right now, but Edge now supports document.evaluate
. Just when (almost) everything switched to JSON for data exchange. Well, better late than never, I guess.
querySelector/All
was supported in IE9. – SorbosequerySelector/All
supports the CSS selector language. XPath is a (more powerful) language to select/analyze nodes in *ML documents. The point of this post is to question the existence of a cross-browser selector language for XML documents. – HebridesquerySelector/All
is and what XPath is. I was merely referring to the statement in your post saying "but it's not supported in IE9 and lower". This is incorrect. It should be "IE8 and lower". I'm not saying that makes a meaningful difference to this question or your answer. – SorbosequerySelector
is supported by IE8 too, but not on XML nodes. IE10 is the first IE that handles XMLs as standard DOM documents. – Hebrides