Firefox Msxml2.DOMDocument equivalently

Posted on 2007-07-25
Last Modified: 2013-12-07
Hi, I have a code and trying to adept to firefox

// IE Version

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

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

Question by:karanba
    LVL 12

    Expert Comment

    Here is a verbose way that should work:
    function TransformXmlWithXsl(xmlDocumentPath, xslDocumentPath){        
     var xsltProcessor = new XSLTProcessor();
    // *** load the XSL file
    var myXMLHTTPRequest = new XMLHttpRequest();"GET", xslDocumentPath, false);
    // *** get the XML document
    xslStylesheet = myXMLHTTPRequest.responseXML;
    // *** load the xml file
    myXMLHTTPRequest = new XMLHttpRequest();"GET", xmlDocumentPath, false);
    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.

    Author Comment

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

    What about fisrt part I try DOmParser but there in no propert to see xmlstring in it.
    LVL 12

    Accepted Solution


    //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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    Title # Comments Views Activity
    Zoom web page in 2 20
    Why does this function not work? 11 54
    Javascript newbie 5 30
    DataTables Form Input issue. 3 25
    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
    Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now