Search code examples
xmlinternet-explorer-9

MSXML DOM could not load synchronously XML from URL in IE9


I load XML from aspx page by MSXML2.DOMDOCUMENT.3.0 ActiveXObject.

        var xmlDoc = null;
        try {
            xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
            xmlDoc.setProperty("SelectionLanguage", "XPath");
        }
        catch (e) {
            window.alert("CreateXMLDocument failed due to the following problem:  " + e.description);
        }

        if (xmlDoc != null) {
            xmlDoc.async = false;**
            var result = xmlDoc.load("xmlData.aspx");
            if (result == false) {
                window.alert("failed to load xml due to the following problem:  " + xmlDoc.parseError.Reason);
            }
            else {
                window.alert(xmlDoc.selectSingleNode("//RESULT").text);
            }
        }

aspx page that provides xml data:

    <%@ Page Language = "JScript" EnableSessionState="ReadOnly" %>
    <% Response.Buffer = true %>

    <%
    Response.ContentType = "text/xml";
    Response.Write("<?xml version='1.0'?>");
    Response.Write("<RESULT>1</RESULT>");
    %>
  • If these two pages are running under http, I can get popup saying "1" in IE9;
  • If these two pages are running under https, I only can get the error popup, which means xml is not loaded successfully.
  • But if I change xmlDoc.async = true and use ondataavailable callback function to get data, it will popup "1".

Any idea about this?

UPDATE: I figured out that XMLDOM could not load xml synchronously from https in IE9, and then used XMLHTTP to load xml with no problems. But now the problem is XMLHTTP-loaded xslt could not be used to transform xml.

UPDATE AGAIN: It's not correct to say that XML DOM could not load xml synchronously from https in IE9. In IE9 Internet Options --> Advanced --> Security --> "Do not save encrypted pages to disk", if you have it checked, the issue occurs. Uncheck it, problem is solved.


Solution

  • You should read this for an explanation:

    Avoid “Do not save encrypted pages to disk” archive