Synchronous Load method for Mozilla and Internet Explorer

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');
    else
      xmlhttp = new XMLHttpRequest();

    if (xmlhttp)
    {
      xmlhttp.open('GET', sourceURL, false);
      xmlhttp.send(null);
      doc = xmlhttp.responseXML;
    }

    return doc;
}

/bc

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