1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <!DOCTYPE html> <html> <head> <script> function loadXMLDoc(filename){ if (window.ActiveXObject){ xhttp = new ActiveXObject("Msxml2.XMLHTTP"); }else{ xhttp = new XMLHttpRequest(); } xhttp.open("GET", filename, false); try {xhttp.responseType = "msxml-document"} catch(err) {} xhttp.send(""); return xhttp.responseXML; } function displayResult(){ xml = loadXMLDoc("mywebsites.xml"); xsl = loadXMLDoc("mywebsites.xsl"); if (window.ActiveXObject || xhttp.responseType == "msxml-document"){ ex = xml.transformNode(xsl); document.getElementById("example").innerHTML = ex; }else if (document.implementation && document.implementation.createDocument){ xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml, document); document.getElementById("example").appendChild(resultDocument); } } </script> </head> <body onload="displayResult()"> <div id="example" /> </body> </html>
|