Results 1 to 6 of 6

Thread: DOMParser issue in IE8

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    55
    Answers
    2

    Default Answered: DOMParser issue in IE8

    Hi,

    Here i am using the following code for convert string to xml.

    xmlDocument = new DOMParser().parseFromString( str, "application/xml" );

    This code working fine in firefox.

    But i got the following error in IE8.

    'Error: 'DOMParser' is undefined'

    Please let me know how to handle in IE8.

    Thanks.

  2. DOMParser does not exist in IE8, you'll have to do something like this:

    Code:
    var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
    xmlDocument.async = false;
    xmlDocument.loadXML(str);

  3. #2
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    337
    Answers
    62

    Default

    DOMParser does not exist in IE8, you'll have to do something like this:

    Code:
    var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
    xmlDocument.async = false;
    xmlDocument.loadXML(str);

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    55
    Answers
    2

    Default

    Its working fine. Thanks.

    How can i handle this in Chrome?

    Thanks.

  5. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    55
    Answers
    2

    Default

    Thanks for your reply.

    Its not working with Chrome.

    Thanks.

  7. #6
    Sencha User makana's Avatar
    Join Date
    Apr 2008
    Location
    Dresden, Germany
    Posts
    527
    Answers
    3

    Default The main difference is a try-catch

    Hello guys,

    please move this thread into Bugs.

    The main difference between the jQuery code and the ExtJS code is a try-catch-block, which is important.

    If you have ActiveX disabled in your IE, then you get an error "component can't create object".

    And you have no chance to override this piece of code since it is an immediately called anonymous function. Please fix this [4.2.x].

    Ext.dom.Query
    Code:
    supportsColonNsSeparator = (function () {
        var xmlDoc,
            xmlString = '<r><a:b xmlns:a="n"></a:b></r>';
    
        if (window.DOMParser)
        {
            xmlDoc = (new DOMParser()).parseFromString(xmlString, "application/xml");
        }
        else
        {
            try
            {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.loadXML(xmlString);
            }
            catch (e)
            {
                return false;
            }
        }
    
        return !!xmlDoc.getElementsByTagName('a:b').length;
    })(),
    Programming today is a race between software engineers striving to build bigger and better ?diot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)

    Enhanced ExtJS adapter for Adobe AIR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •