Error in transformNode in IE8



following code is working in chrome but not in IE8 . can you please help on it.



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) {} // Helping IE11
xhttp.send();
//alert("response:::"+xhttp.responseText);
return xhttp.responseXML;
}



function displayResult()
{
var xmlurl=window.location.ref="<%=request.getContextPath()%>/GenerateXMLServlet";
var xslurl=window.location.ref="<%=request.getContextPath()%>/GenerateXSLServlet";

xml = loadXMLDoc(xmlurl);
xsl = loadXMLDoc(xslurl);
// code for IE
if (window.ActiveXObject || xhttp.responseType == "msxml-document") {

ex = xml.transformNode(xsl); // getting error on this line
document.getElementById("example").innerHTML = ex;
}
// code for Chrome, 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);
}
}


we are getting the following javascript error : "The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document."


No comments:

Post a Comment