• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2451
  • Last Modified:

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);        
}

         
0
karanba
Asked:
karanba
  • 2
1 Solution
 
jkmyoungCommented:
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.
0
 
karanbaAuthor Commented:
// 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.
0
 
jkmyoungCommented:
http://www.webreference.com/programming/javascript/domwrapper/3.html

//create a DOMParser
var objDOMParser = new DOMParser();

//create new document from string
var objDoc = objDOMParser.parseFromString(xmlString, "text/xml");

The article expands more on how to manipulate the objDoc if you need it.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now