Wednesday, 24 August 2011

How to make XML parsing compatible with IE

Internet Explorer is annoying as usual about this and you need to make exceptions for it.  Here's what you can do:

type: 'GET',
                        url: 'photos.xml',
                        dataType: ($.browser.msie) ? "text" : "xml", //if Browser is internet explorer, the datatype is text, otherwise xml.
                        success: getXML,
                        complete:


And then in my "success" function, add this:

if ($.browser.msie) {
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.loadXML(xml);
    xml = xmlDoc;
}

No comments:

Post a Comment