IE10 in Windows 8 Release Preview updates
the responseXML
from an XMLHttpRequest
to return a native
XML document by default. This change applies to IE10’s Standards and Quirks
document modes, making them interoperable with other modern browsers and consistent
with a “same markup” approach. Compatibility document modes 5, 7, 8, and 9 are unchanged.
This change may impact sites that were expecting responseXML
to contain
an MSXML document and depended on MSXML-specific functionality such as selectNodes
. In these cases, you may request that IE10 return an MSXML by setting
the responseType
member of your XMLHttpRequest
object to 'msxml-document'
. If your code does not depend on MSXML-specific functionality, IE10’s native XML document should work for you.
Native XML support in IE9 brought DOM parity to XML and HTML and enabled XML fragments
to be inserted and rendered directly within a page (even in HTML). IE9 also simplified
converting between XML and DOM with the addition of
DOMParser and XMLSerializer. IE10 completes this transition by updating
responseXML
to return a native XML document.
Like IE9, IE10 previews before the Windows 8 Release
Preview returned an
MSXML document for responseXML
. As a result, retrieving
a native document required the additional step of passing responseText
to DOMParser
.
var xhr = new
XMLHttpRequest();
//...
var parser = new
DOMParser();
var doc = parser.parseFromString(xhr.responseText,
'text/xml');
// 'doc' contains a native document
in both IE9 and IE10
In the Windows 8 Release Preview, IE10 eliminates the need for an additional DOMParser
step by returning a native document directly via responseXML
. Existing
code using DOMParser
will continue to work in IE10.
var xhr = new
XMLHttpRequest();
//...
var doc = xhr.responseXML;
// 'doc' contains a native document
in IE10’s Standards and Quirks document modes
// it contains an MSHTML document
in IE9 and in IE10’s compatibility document modes
This simplification also applies to the new response
property when
responseType
is set to 'document'
.
var xhr = new
XMLHttpRequest();
xhr.open(method, url, true);
xhr.responseType = 'document';
//...
var doc = xhr.response;
// 'doc' contains a native document
in IE10’s Standards and Quirks document modes
IE10 additionally includes a mechanism to opt-in to retrieving an MSXML document.
This can be useful if you still need some MSXML-specific functionality (such as
) or simply need some extra time to migrate. To do this, set
selectNodes
the responseType
of your XMLHttpRequest
object to 'msxml-document'
.
var xhr = new
XMLHttpRequest();
xhr.open(method, url, true);
try { xhr.responseType =
'msxml-document'; } catch(e){}
//...
var doc = xhr.responseXML;
// 'doc' now contains an MSXML document
in IE10’s Standards and Quirks document modes
In theory the assignment should be ignored by other browsers, but in practice some
do throw an exception. You can defend against this using a try/catch
statement, as in the above example.
—Tony Ross, Program Manager, Internet Explorer