Link to home
Start Free TrialLog in
Avatar of karanba
karanba

asked on

Firefox Msxml2.DOMDocument equivalently

Hi, I have a code and trying to adept to firefox


// IE Version

// first part
var xmlDocument = new ActiveXObject("Msxml2.DOMDocument.4.0");
      xmlDocument.loadXML(xmlString);        


// second part
function TransformXmlWithXsl(xmlDocumentPath, xslDocumentPath){        
    var xml = xmlDocumentPath;        
    var xsl = new ActiveXObject("Msxml2.DOMDocument.4.0");
        xsl.async = false;
        xsl.load(xslDocumentPath);        
        return xml.transformNode(xsl);        
}

         
Avatar of jkmyoung
jkmyoung

Here is a verbose way that should work:
function TransformXmlWithXsl(xmlDocumentPath, xslDocumentPath){        
 var xsltProcessor = new XSLTProcessor();
// *** load the XSL file
var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", xslDocumentPath, false);
myXMLHTTPRequest.send(null);
// *** get the XML document
xslStylesheet = myXMLHTTPRequest.responseXML;
 xsltProcessor.importStylesheet(xslStylesheet);
// *** load the xml file
myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", xmlDocumentPath, false);
myXMLHTTPRequest.send(null);
var xmlSource = myXMLHTTPRequest.responseXML;
// *** transform
return xsltProcessor.transformToFragment(xmlSource, document);
}

the XMLHTTPRequest's really aren't necessary, but I'm not sure what you're sending in.
Also, you might want the transformToDocument function instead of fragment, but again that's up to you.
Avatar of karanba

ASKER

// first part
var xmlDocument = new ActiveXObject("Msxml2.DOMDocument.4.0");
      xmlDocument.loadXML(xmlString);  


What about fisrt part I try DOmParser but there in no propert to see xmlstring in it.
ASKER CERTIFIED SOLUTION
Avatar of jkmyoung
jkmyoung

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial