Dhvl Pithva Dhvl Pithva - 7 months ago 113
jQuery Question

XSLT transformation issue in IE 11

I am trying to transform XML using XSLT.
It Works Perfectly on FF , Chrome , IE upto 10.
But in IE-11 its not Working .
Here is a Sample code i am using.

function TransformXML(XmlPath, XsltPath) {
xml = loadXMLDoc(XmlPath);
xsl = loadXMLDoc(XsltPath);
// code for IE
if (window.ActiveXObject || "ActiveXObject" in window){
ex = xml.transformNode(xsl);
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
xsltProcessor = new XSLTProcessor();
var xmldom = xsltProcessor.transformToDocument(xml);
var serializer = new XMLSerializer();
var transformed = serializer.serializeToString(xmldom.documentElement);


I guess the problem is in loadXMLDoc(XsltPath), so we need to see the code of that function. IE used to return an MSXML DOM document as responseXML and MSXML supports XSLT with transformNode. Recent IE versions return an IE DOM document as responseXML and don't support XSLT (nor with transformNode nor at all). If you want to use XSLT and load the stylesheet code with XMLHttpRequest then you need e.g.

function loadXMLDoc(url) {
  if (typeof XMLHttpRequest !== 'undefined')
    var xhr = new XMLHttpRequest();
    xhr.open(method, url, false);
    // request MSXML responseXML for IE
    try { xhr.responseType = 'msxml-document'; } catch(e){}
    return xhr.responseXML;
  else {
    try {
      var xhr = new ActiveXObject('Msxml2.XMLHTTP.3.0');
      xhr.open('GET', url, false);
      return xhr.responseXML;
    catch (e) {
      // handle case that neither XMLHttpRequest nor MSXML is supported