// Javascript
// This file handles the XML file
// ************************************************************************
// Read in the xml format file
// Then calls processData when loaded
// ************************************************************************

function importXML(filename)
{
  var thisFunct = "xml.js:importXML(): ";
  debug(thisFunct + "Entry");

  var my_xmlDoc;
  if (window.XMLHttpRequest)
    {
    debug(thisFunct + "XMLHttpRequest route");
    my_xmlDoc=new window.XMLHttpRequest();
    my_xmlDoc.open("GET",filename,false);  // Synchronous version, wait for the document to load
    my_xmlDoc.send("");
//    debug(thisFunct + my_xmlDoc.responseText);

    }
  // IE 5 and IE 6
  else if (ActiveXObject("Microsoft.XMLDOM"))
    {
    debug(thisFunct + "Microsoft.XMLDOM route");
    my_xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    my_xmlDoc.async=false;
    my_xmlDoc.load(filename);
  //  debug(thisFunct + my_xmlDoc.responseText);
    }
  else
    alert("Error loading document");



  // OK, we've got this far, so we've got the file
  // Now we need to persuade the browser to accept it as XML
  debug(thisFunct + "Parse the file we've just read");
  try //Internet Explorer
  {
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    // Print the message after we try, if an exception is generated we won't print it
    debug(thisFunct + "Using the ActiveX way of parsing the XML file");
    xmlDoc.async="false";               // Synchronous version, wait for the document to load
    xmlDoc.loadXML(my_xmlDoc.responseText);
    debug(thisFunct + "Success; Exit reader");
    return;
  }
  catch(e)
  {
    debug(thisFunct + "Using the DOMParser() way of parsing the XML file");
    parser=new DOMParser();
    xmlDoc=parser.parseFromString(my_xmlDoc.responseText,"text/xml");
    debug(thisFunct + "Success; Exit reader");
    return;
  }

  return;
};

