Jaa


XMLHttpRequest responseXML in IE10 Release Preview

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 selectNodes) or simply need some extra time to migrate. To do this, set
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

Comments

  • Anonymous
    July 19, 2012
    The lack of IE 10 news for Windows 7 is disturbing.

  • Anonymous
    July 19, 2012
    @Tony Ross and MSIE team: Can you publish an article about the HTML5 WebGL technology that is coming up in IE10? You know, we web developers just can't wait to hear about it.

  • Anonymous
    July 19, 2012
    @HTML5 & IE10 You mean "you, web troller".

  • Anonymous
    July 19, 2012
    Thanks for the info. Let's see how it works when there's a beta build for Windows 7, meanwhile I'll keep using the next versions of the rest of browsers, you know, those that don't hate Windows 7 like Microsoft does.

  • Anonymous
    July 19, 2012
    @the troll: here's Microsoft's stance on webgl: blogs.technet.com/.../webgl-considered-harmful.aspx

  • Anonymous
    July 19, 2012
    Ah yes, the dreaded not-quite-XML responseXML.  While I was trying to make an SVG game I was experimenting with XHR to try to load other things into the game's "stage" on demand, and ran into this. An article on A List Apart gave a workaround to get the XML result to be properly recognized but that didn't quite fix my problems; I hope this does.

  • Anonymous
    July 19, 2012
    The comment has been removed

  • Anonymous
    July 19, 2012
    Just would like to point out to the clueless that WebGL is not a HTML5 standard.  It is not published by W3C.

  • Anonymous
    July 19, 2012
    "that WebGL is not a HTML5 standard" that has never stopped MS from implementing it anyway.

  • Anonymous
    July 19, 2012
    The W3C isn't the only organization that creates HTML5 open specifications for the web. The HTML5 WebGL specification is published by Kronos, the same group that is also responsible for OpenGL. WebGL is listed as one of the HTML5 technologies on the W3C HTML5 logo page: http://www.w3.org/html/logo/ Here's what we can read on that W3C website: "Between SVG, Canvas, WebGL, and CSS3 3D features, you're sure to amaze your users with stunning visuals natively rendered in the browser."

  • Anonymous
    July 20, 2012
    The fact that Microsoft ever had their own version of XML (a universal markup language for arbitrary content of any kind) just goes to show you how utterly messed up Microsoft really is. XML is XML... there is no need for an MS version of XML aka "MSXML". @Developers! Seriously consider where you get your guidance on developing for the Web... obviously Microsoft is the absolute last place you should look!

  • Anonymous
    July 20, 2012
    The comment has been removed

  • Anonymous
    July 20, 2012
    @warrens : "IE10 in Windows 8 Release Preview updates the responseXML from an XMLHttpRequest to return a native XML document by default." You either have a valid XML version 1.0 document or you don't.  It sounds like Microsoft has messed this up for years and only now finally fixed the issue. Only 12 years late Microsoft - well done!

  • Anonymous
    July 20, 2012
    @Taylor: It's not about differences in the XML per se. It's that the MSXML library exposed a set of methods for operating on the XML document which are different or missing in the standardized XML DOM implementation of IE10.

  • Anonymous
    July 20, 2012
    @WebGL is an HTML5 standard: >>> WebGL is listed as one of the HTML5 technologies on the W3C HTML5 logo page: http://www.w3.org/html/logo/ Where? I can't see it.

  • Anonymous
    July 20, 2012
    The comment has been removed

  • Anonymous
    July 21, 2012
    If (new XMLHttpRequest()).responseType is set to an unsupported value, it should throw an exception. For example; In the UA's console run the following code: (function IsArrayBufferSupported(){    var xhr = new XMLHttpRequest();    xhr.open('GET', '/', true);    try{     xhr.responseType = "arraybuffer";     return true;    }catch(e){return false;} })(); This should return true. Which it does in IE, FF, Opera, Chrome and Safari. Then run: (function IsArrayBufferSupported(){    var xhr = new XMLHttpRequest();    xhr.open('GET', '/', true);    try{     xhr.responseType = "badValue";     return true;    }catch(e){return false;} })(); This should return false. Which it does in Chrome (19.0.1...) and Safari (5.1.2) only. All other browsers including IE9 and 10RP return ture. "e.message" in both Safari and Chrome is: SYNTAX_ERR: DOM Exception 12 In short, xhr.responseType = "badValue"; should throw an exception

  • Anonymous
    July 21, 2012
    Feedback Item on connect: connect.microsoft.com/.../xmlhttprequest-no-exception-is-fired-when-responsetype-is-set-the-a-not-supported-value

  • Anonymous
    July 21, 2012
    @Xero - dvcs.w3.org/.../Overview.html or www.w3.org/.../XMLHttpRequest do not state anywhere that an exception must/should be thrown (unless I am missing something), so, unfortunately, apparently, WebKit is doing the non standardized (sort of) thing here.

  • Anonymous
    July 21, 2012
    @PhistucK, Microsoft stated the same thing on Connect bug report that W3 may specify more responseTypes in future, which is why its open ended. Just for sake of argument, if the UA checks whether the set value is defined in the underlying engine (for example; exists in responseTypeENUM) and throw exception otherwise, it would save the run-time error. The W3 sepcs are neither enforcing nor negating this aspect, so UA vendor can rescue the erroneous code path, right?

  • Anonymous
    July 21, 2012
    The comment has been removed

  • Anonymous
    July 22, 2012
    The comment has been removed

  • Anonymous
    July 24, 2012
    We have updated the release date for IE10. It looks like we will get the IE10 RTM very soonish. Microsoft will supposedly release Windows 8 RTM in early August. Together with the RTM release ships a copy of IE10 RTM.

  • Anonymous
    July 24, 2012
    @Eric - OMG! Are you serious? Neither Windows 8 nor IE10 is ready for prime time! please point to your source! We haven't even had the IE10 Beta on Windows 7 yet! (when the f_u_d_g_e was Microsoft thinking we were going to do ALL OF OUR TESTING?!?!?)