IE7 XML Extras
The XMLHttpRequest
object has been getting some renewed attention lately. This is due to it being implemented in two more browsers (Opera and Safari). It was originally introduced by Microsoft in IE5.0 using (despised) ActiveX technology. It first appeared as a native JavaScript object as part of Mozilla’s XML extras and is now on its way to becoming a standard.
A new IE7 module (ie7-xml-extras.js
) provides an emulation of Mozilla’s XML objects:
- XMLHttpRequest
- DOMParser
- XMLSerializer
This new module provides wrappers for the underlying ActiveX objects. This is a slightly heavy handed way to implement cross-browser support and more lightweight solutions have been around for a while. But if you are a purist, then you may want to download the code. Although the module is part of IE7 it will also work as a standalone module.
Comments (20)
Leave a comment
Comment: #1
Great stuff! Unless you get there first, may drop by something with some of the other stuff Mozilla’s implementation has (e.g. onload / onerror / addEventListener() etc.).
Comment: #2
xmlhttprequest info: XMLHttpRequest Introduction IE 7 xml-extras xmlhttprequest calendar
Comment: #3
Excellent! Just the one platform to target, now for XMLHttp as well.
Comment: #4
What am I doing wrong here?
http://www.dougweb.org/xmlhttp/index.html
It works in Gecko, but not IE..
Comment: #5
Doug, it seems that Microsoft’s
responseXML
property is not the same as Mozilla’s. I need to code around this. Expect an update soon.Comment: #6
Please note that you should wrap the script in conditional comments as described in the IE7 usage page.
Comment: #7
Why not have also a DOM3 XPath implementation as mozilla do ?
See http://blogs.msdn.com/dareobasanjo/archive/2004/04/20/116815.aspx
Comment: #8
Dean – was comment 6 directed at me, or a general warning to all? Because I am using the conditional comments.
Comment: #9
Doug, it was a general comment. Seeing your test page reminded me to remind everyone else.
Comment: #10
I vote “yeay!” to the XPath extension! (now at https://sourceforge.net/projects/html-xpath/)
Comment: #11
Dimitri Glazkov (the author of the XPath extension) and I have already spoken about his project eventually becoming an IE7 module. The birth of his baby boy slowed down development a little as I recall.
Maybe it’s time to contact Dimitri again…
Comment: #12
Whoa. A blog and everything. I must’ve been really caught in the “newborn time warp”
I would be very interested in getting the html-xpath project integrated as an extension. Time, as was mentioned earlier, still comes at a premium, but I think I may have more of it now.
Comment: #13
This blogging thing really works…
Comment: #14
Dean, this is great! One small addition by me – even if it is faked up. I am working on something crossbrowser and found a script that attaches an onload handler to the request object. alike
this point the script did continue in a mozilla firefox browser but stalled in IE 6. So I modified your solution to make it work – but as I said before I have no idea if I have done it the right way.
But what to do about the onerror handler? regards ralf
Comment: #15
Does anyone know of any documentation on how to use IE 7 xml Exrtas? I have been reading up but I’m having trouble finding a useful source.
Comment: #16
What problems are you having Tom? You should be able to use the XMLHttpRequest the same as you can in Mozilla:
http://www.mozilla.org/xmlextras/
Remember to include the script in conditional comments to hide it from non-IE browsers:
There is lots of additional information here:
http://jpspan.sourceforge.net/wiki/doku.php?id=javascript:xmlhttprequest
Comment: #17
Doug, you are using the wrong mime-type on the page you’re retrieving; it’s not xml. Change and it will work. Or use a different function with responseText instead (much better if you just want a snippet anyway).
Dean, doesn’t seem to be a problem with responseXML in your code as you think. Works fine for me but then so does one line assigning new xmlhttprequest to new activexobject for ie without all the extra code so I was wondering what all you were trying to fix in that module (not including the extras there).
Comment: #18
[…] I just noticed that Dean Edwards’ IE compatibility layer has been updated with a new xml objects module which can emulate Mozilla’s xmlhttprequest functionality. wordpr […]
Comment: #19
Dean, Any word on the .responseXML issues?
Great work, thanks
Comment: #20
Michael, version 0.9 of IE7 includes a simpler wrapper for the
XMLHttpRequest
object. Hopefully this will solve the problem you are experiencing.Comments are closed.