I am using the following javascript code to display xml / xsl:
function loadXMLDoc(fname)
{
var xmlDoc;
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation
&& document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
try {
xmlDoc.async=false;
xmlDoc.load(fname);
return(xmlDoc);
}
catch(e)
{
try
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",file,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
return(xmlDoc);
}
catch(e)
{
error=e.message;
}
}
}
function displayResult()
{
xml=loadXMLDoc("report.xml");
xsl=loadXMLDoc("report.xsl");
if (window.ActiveXObject)
{
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);
}
}
This works for IE and Firefox, but chrome doesn't work on line:
document.getElementById("example").appendChild(resultDocument);
Thanks for helping
source
share