﻿function loadXMLDoc(dname) {
    if (window.XMLHttpRequest) {
        xhttp = new XMLHttpRequest();
    }
    else {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET", dname, false);
    xhttp.send("");
    return xhttp.responseXML;
}

function displayXML(divId, xmlFile, xslFile, nocache) {
    if ((nocache) && (nocache == true)) {
        xmlFile += "?nocache=" + new Date().getTime();
        }

    xml = loadXMLDoc(xmlFile);
    xsl = loadXMLDoc(xslFile);
    // code for IE
    if (window.ActiveXObject) {
        ex = xml.transformNode(xsl);
        document.getElementById(divId).innerHTML = ex;
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument) {
        var element = document.getElementById(divId);
        while (element.firstChild) {
            element.removeChild(element.firstChild);
        }
        xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(xsl);
        resultDocument = xsltProcessor.transformToFragment(xml, document);
        document.getElementById(divId).appendChild(resultDocument);
    }
}

