New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE9 XMLSerializer serializeToString fails to handle Ajax XML #127

Closed
rkernahan opened this Issue Feb 15, 2012 · 5 comments

Comments

Projects
None yet
3 participants
@rkernahan

rkernahan commented Feb 15, 2012

Built a test case to demonstrate that in IE9 serializeToString works fine on local XML data (embedded in the HTML page) but fails to serialize XML data loaded via Ajax (ie. different documentOwner).

Fails with message "No such interface supported".
IE9 implements the XMLSerializer object and has a member called serializeToString but it is not implemented (gives the error message just mentioned).

If I cannot attach a test case, I'll send it by email.

@rkernahan

This comment has been minimized.

Show comment
Hide comment
@rkernahan

rkernahan Feb 15, 2012

testcase.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test case for XMLSerializer</title>
    <script type="text/javascript" src="runtime-dev.js"></script>
    <script type="text/javascript" src="xhtml.js"></script>
    <style type="text/css">
        #viewLocal, #viewAjax {
            height: 120px;
            width: 400px;
            margin: 10px;
            padding: 2px;
            overflow: auto;
            border: 1px solid #aaa;
        }
    </style>
</head>
<body>
    <h1>Test case for XMLSerializer in IE9</h1>

    <p>Press '<em>Load local data</em>' to load some data from the page itself and convert it to a string.</p>
    <button onclick="loadLocal()">Load local data</button>
    <div id="viewLocal">-- no data --</div>

    <p>Press '<em>Load Ajax data</em>' to serialize XML loaded via Ajax.</p>
    <button onclick="loadAjax()">Load Ajax data</button>
    <div id="viewAjax">-- no data --</div>

    <script type="text/javascript">
        function loadLocal() {
            // get the XML from the document as a string; then parse it to XML so we can exercise serializeToString()
            var sRaw = document.getElementById('t1').innerHTML;
            var dp = new DOMParser();
            var oDoc = dp.parseFromString(sRaw, 'text/xml');
            var oRoot = oDoc.documentElement;
            var oXS = new XMLSerializer();
            var sXML = oXS.serializeToString(oRoot);
            document.getElementById('viewLocal').innerHTML = sXML.replace(/\</g,'&lt;').replace(/\>/g, '&gt;').replace(/\n/g,'<br/>');
        }
        function loadAjax() {
            var that = this;
            var oRequest = {};
            oRequest.type = 'GET';
            oRequest.dataType = 'xml';
            oRequest.url = 'vanuatu.xml';
            oRequest.error = function(oXHR) {
                alert('failed to load XML from vanuatu.xml');
            };
            oRequest.success = function(oDoc, success, oXHR) {
                var oRoot = oDoc.documentElement;
                var oXS = new XMLSerializer();
                var sXML = oXS.serializeToString(oRoot);
                console.log(sXML);
                document.getElementById('viewAjax').innerHTML = sXML.replace(/\</g,'&lt;').replace(/\>/g, '&gt;').replace(/\n/g,'<br/>');
            }
            ample.ajax(oRequest);
        }
    </script>

    <script type="text/xml" id="t1">
        <dataSet>
            <record id='SQT26NWC'>
                <company>Jayme Winters</company>
                <price>80</price>
                <increase>0</increase>
                <state>SQT26NWC</state>
                <email>sit.amet@elitpellentesque.edu</email>
            </record>
            <record id='RJI15OAB' disabled="true">
                <company>Elaine Morrow</company>
                <price>89</price>
                <increase>1</increase>
                <state>RJI15OAB</state>
                <email>at.lacus.Quisque@nonummyac.com</email>
            </record>
            <record id='XWE64AEE'>
                <company>Darrel Obrien</company>
                <price>79</price>
                <increase>0</increase>
                <state>XWE64AEE</state>
                <email>Cras@estacfacilisis.org</email>
            </record>
        </dataSet>
    </script>

</body>
</html>

rkernahan commented Feb 15, 2012

testcase.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test case for XMLSerializer</title>
    <script type="text/javascript" src="runtime-dev.js"></script>
    <script type="text/javascript" src="xhtml.js"></script>
    <style type="text/css">
        #viewLocal, #viewAjax {
            height: 120px;
            width: 400px;
            margin: 10px;
            padding: 2px;
            overflow: auto;
            border: 1px solid #aaa;
        }
    </style>
</head>
<body>
    <h1>Test case for XMLSerializer in IE9</h1>

    <p>Press '<em>Load local data</em>' to load some data from the page itself and convert it to a string.</p>
    <button onclick="loadLocal()">Load local data</button>
    <div id="viewLocal">-- no data --</div>

    <p>Press '<em>Load Ajax data</em>' to serialize XML loaded via Ajax.</p>
    <button onclick="loadAjax()">Load Ajax data</button>
    <div id="viewAjax">-- no data --</div>

    <script type="text/javascript">
        function loadLocal() {
            // get the XML from the document as a string; then parse it to XML so we can exercise serializeToString()
            var sRaw = document.getElementById('t1').innerHTML;
            var dp = new DOMParser();
            var oDoc = dp.parseFromString(sRaw, 'text/xml');
            var oRoot = oDoc.documentElement;
            var oXS = new XMLSerializer();
            var sXML = oXS.serializeToString(oRoot);
            document.getElementById('viewLocal').innerHTML = sXML.replace(/\</g,'&lt;').replace(/\>/g, '&gt;').replace(/\n/g,'<br/>');
        }
        function loadAjax() {
            var that = this;
            var oRequest = {};
            oRequest.type = 'GET';
            oRequest.dataType = 'xml';
            oRequest.url = 'vanuatu.xml';
            oRequest.error = function(oXHR) {
                alert('failed to load XML from vanuatu.xml');
            };
            oRequest.success = function(oDoc, success, oXHR) {
                var oRoot = oDoc.documentElement;
                var oXS = new XMLSerializer();
                var sXML = oXS.serializeToString(oRoot);
                console.log(sXML);
                document.getElementById('viewAjax').innerHTML = sXML.replace(/\</g,'&lt;').replace(/\>/g, '&gt;').replace(/\n/g,'<br/>');
            }
            ample.ajax(oRequest);
        }
    </script>

    <script type="text/xml" id="t1">
        <dataSet>
            <record id='SQT26NWC'>
                <company>Jayme Winters</company>
                <price>80</price>
                <increase>0</increase>
                <state>SQT26NWC</state>
                <email>sit.amet@elitpellentesque.edu</email>
            </record>
            <record id='RJI15OAB' disabled="true">
                <company>Elaine Morrow</company>
                <price>89</price>
                <increase>1</increase>
                <state>RJI15OAB</state>
                <email>at.lacus.Quisque@nonummyac.com</email>
            </record>
            <record id='XWE64AEE'>
                <company>Darrel Obrien</company>
                <price>79</price>
                <increase>0</increase>
                <state>XWE64AEE</state>
                <email>Cras@estacfacilisis.org</email>
            </record>
        </dataSet>
    </script>

</body>
</html>
@rkernahan

This comment has been minimized.

Show comment
Hide comment
@rkernahan

rkernahan Feb 15, 2012

vanuatu.xml - the data loaded via Ajax

<?xml version="1.0" encoding="UTF-8"?>
<dataset xmlns="">
    <record id="db56">
        <name>Reggae</name>
        <age>24</age>
    </record>
    <record id="aw72">
        <name>Motown</name>
        <age>73</age>
    </record>
</dataset>

rkernahan commented Feb 15, 2012

vanuatu.xml - the data loaded via Ajax

<?xml version="1.0" encoding="UTF-8"?>
<dataset xmlns="">
    <record id="db56">
        <name>Reggae</name>
        <age>24</age>
    </record>
    <record id="aw72">
        <name>Motown</name>
        <age>73</age>
    </record>
</dataset>
@finalstep

This comment has been minimized.

Show comment
Hide comment
@finalstep

finalstep Feb 17, 2012

Duplicate of #125

finalstep commented Feb 17, 2012

Duplicate of #125

@ilinsky

This comment has been minimized.

Show comment
Hide comment
@ilinsky

ilinsky Feb 20, 2012

Member

The problem appear to be caused by Internet Explorer internal inconsistency - it fails running XMLSerializer over its own XMLHttpRequest.responseXML object type. I will apply workaround, though it requires user-agent sniffing.. and it is not known what will be the behavior of IE10.

Member

ilinsky commented Feb 20, 2012

The problem appear to be caused by Internet Explorer internal inconsistency - it fails running XMLSerializer over its own XMLHttpRequest.responseXML object type. I will apply workaround, though it requires user-agent sniffing.. and it is not known what will be the behavior of IE10.

@ilinsky

This comment has been minimized.

Show comment
Hide comment
@ilinsky

ilinsky Feb 21, 2012

Member

Fixed per rev f29445c

Member

ilinsky commented Feb 21, 2012

Fixed per rev f29445c

@ilinsky ilinsky closed this Feb 21, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment