IE and Mozilla recognize CDATA nodetype differently
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

IE and Mozilla recognize CDATA nodetype differently

From: Aziz <rass.elma@googlemail.com>
Date: Sat Feb 04 2006 - 16:54:22 CET

Hi Folks
I am trying to access an HTML code stored as CDATA section in the xml
file listed bellow:

<?xml version="1.0"?>
<results count="5">
<![CDATA[
    <table><tr><td>Hello World</td></tr></table>
]]>
</results>

The xml tree is the responseXML part of an XmlHttpRequest and is stored
in a the javascript object xmldoc. While trying to test the node type
of the children of the "results"-Element I got different results with
IE and Mozilla:

xmldoc.getElementsByTagName("results")[0].childNodes[0].nodeType -->
MN=>TEXT,IE =>CDATA

xmldoc.getElementsByTagName("results")[0].childNodes[1].nodeType -->
MN=>CDATA,IE =>NULL

I added a non empty text node to the result element:
<results count="5">
blalba text
<![CDATA[...

Now I get this:
xmldoc.getElementsByTagName("results")[0].childNodes[0].nodeType -->
MN=>TEXT,IE =>TEXT
xmldoc.getElementsByTagName("results")[0].childNodes[1].nodeType -->
MN=>CDATA,IE =>CDATA

Does someone have an explanation for this behaviour?

I am using Mozilla 1.5 and IE 6

Cheers,
Aziz
Received on Tue Feb 7 21:34:09 2006