W3C home > Mailing lists > Public > www-dom-ts@w3.org > February 2002

Synchronous Load method for Mozilla and Internet Explorer

From: Robert Clary <bclary@netscape.com>
Date: Sat, 23 Feb 2002 21:15:38 -0500
Message-ID: <3C784CCA.2090103@netscape.com>
To: www-dom-ts@w3.org
The following function can be used in both Mozilla and Internet Explorer 
5+ to synchronously load XML Documents.

I have tested it with the Feb 13 build by replacing the code which 
creates an empty Document and then performs Document.load with a simple 
call to this function which will create, load and return a reference to 
the Document. The number of errors and failures is deterministic in 
Mozilla and Internet Explorer using this function.

This can be used for both Mozilla and Internet Explorer and I recommend 
that this approach be taken so long as external XML documents are 
loaded. Note, as far as I know, this is a non validating operation on 
both browsers and will result in tests which require an external DTD to 
be loaded to fail in both browsers.

function GetXMLFile(sourceURL)
    var xmlhttp = null;
    var doc = null;

    if (document.all)
      xmlhttp = new ActiveXObject('MSXML2.XMLHTTP');
      xmlhttp = new XMLHttpRequest();

    if (xmlhttp)
      xmlhttp.open('GET', sourceURL, false);
      doc = xmlhttp.responseXML;

    return doc;

Received on Saturday, 23 February 2002 21:20:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:15 UTC