首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:XSLT 教程
TRY RUN / 在线示例
XSLT 教程 尝试一下
XSLT 教程 尝试一下
源代码
运行
<html> <head> <script> function loadXMLDoc(dname) { if (window.ActiveXObject) { xhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0"); } else { xhttp=new XMLHttpRequest(); } xhttp.open("GET",dname,false); xhttp.send(""); return xhttp.responseXML; } function displayResult() { xml=loadXMLDoc("cdcatalog.xml"); xsl=loadXMLDoc("cdcatalog.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. 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"></div> </body> </html>
运行结果