DMGambone / JXON-Parser

Converts an XML document into a JSON object
7 stars 3 forks source link

Will not work in IE8 #1

Closed julkue closed 9 years ago

julkue commented 9 years ago

After using the plugin in IE8 I got the following error: type mismatch jxon.js, line 177 character 4 @DMGambone

DMGambone commented 9 years ago

Do you have a sample XML?

julkue commented 9 years ago
<?xml version="1.0" encoding="UTF-8"?>
<HTMLVideoMapper xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/HTMLVideoMapper.xsd">
    <HTMLFile filename="N5670A">
        <variant>1</variant>
        <overlayTitle>Job Cards</overlayTitle>
        <groups>
            <group>
                <groupTitleBtn>true</groupTitleBtn>
                <name>Removing thermostat</name>
                <src>03-8.2.12.15-10.13.35_MTU_20V8000M91</src>
                <steps>
                    <step number="1">
                        <start>0</start>
                    </step>
                </steps>
            </group>
        </groups>
    </HTMLFile>
</HTMLVideoMapper>

Note: I use parser.parseXML() not parser.parseXMLFile() since I load the XML file myself.

DMGambone commented 9 years ago

Unfortunately, I can't seem to reproduce it in IE8, IE8 Quirks Mode, IE7, or IE7 Quirks Mode.

How are you calling the parsing method? Here is how I tested it (after placing your XML into a file called data.xml):

        var parser = new JXON.Parser();
        var result = parser.parseXMLFile("data.xml");
julkue commented 9 years ago

Thanks for the response. In my last reply I've described how I call the plugin.

DMGambone commented 9 years ago

Sorry, I missed that.

I've tried that as well, but still no issues. Now, I'm testing in IE9 using IE8 browser and document modes. This generally will work to mimic IE8, but that could be why I'm not seeing the issue.

Here's the updated example:

        var jxon = new JXON.Parser();
        var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><HTMLVideoMapper xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"../xsd/HTMLVideoMapper.xsd\"><HTMLFile filename=\"N5670A\"><variant>1</variant><overlayTitle>Job Cards</overlayTitle><groups><group><groupTitleBtn>true</groupTitleBtn><name>Removing thermostat</name><src>03-8.2.12.15-10.13.35_MTU_20V8000M91</src><steps><step number=\"1\"><start>0</start></step></steps></group></groups></HTMLFile></HTMLVideoMapper>";
        var result = jxon.parseXML(xml);
julkue commented 9 years ago

Hey. I'm currently sick but on my next working day I'll try to set up a isolated demonstration of the problem.

julkue commented 9 years ago

I'm very sorry for the late response. I had to develop another project, but now I'm back to the one with that problem. However, I found the problem. It seems that my file loader that loads the XML has a bug. It's response was a object not a string, but only in IE8. That's why the error came up. So it was my fault. However, maybe you could check typeof param === "string" before working with the given XML string.

The problem is that jQuery parses the loaded XML file directly without calling the $.parseXML manually. That's why the loaded xml file was a object instead of a string. After switching to native XMLHttpRequest it worked for me.

Thanks for your help.