Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I am creating CDATA section as a child node. I have seen below mentioned behavior with Firefox, IE8,9, and 10
 
Using below code
 
if (window.DOMParser)
       xmlDoc = domParser.parseFromString(xmltext, "text/xml");
   else //IE
       xmlDoc.loadXML(strXML);
 
  var elem= xmlDoc.createElement("a");
 
 elem.appendChild(xmlDoc.createCDATASection("some value"))
 
With IE,8,9, and firefox if i pass empty string , it still creates CDATA section with nothing in bracket like below
<a sd="7493" re="453" yh="67"><![CDATA[]] > </a>
But with IE 10 , it does not create CDATA if no value is passed in createCDATASection. Also with IE10, it passes window.DomParser check. Also if make IE10 also load xml like xmlDoc.loadXML(strXML); then it does create CDATA for IE10 as well.
 
Can anyone explain why such kind a behavior
Posted 30-Apr-13 11:19am
Comments
Sergey Alexandrovich Kryukov at 30-Apr-13 17:20pm
   
This is illogical question. You cannot say that the code created empty CDATA "with IE 10". The code generating XML does not depends on the browser you use to see the result. Take a text editor and see what's generated. Check up your observation, and them formulate the problem correctly, if you still see it.
—SA
devcode007 at 30-Apr-13 17:46pm
   
I am saying IE 10 does not created Child node for element a i.e with IE 9 same code creates
 
(less than)a sd="7493" re="453" yh="67"> [CDATA[]] a> but with IE 10 same code creates
(less than)a sd="7493" re="453" yh="67"> a> (No Child node)
</pre>
The only difference in code is creating xmlDoc.
IE 9 uses : xmlDoc.loadXML(xmltext);
IE 10 uses: xmlDoc = domParser.parseFromString(xmltext, "text/xml");
 
I confirmed this behavior by extracting XML and observing all the nodes created.
Below is the code used to retrieve xml
Var tempxml;
if (window.DOMParser)
tempxml = new XMLSerializer().serializeToString(xmlDoc);
else
tempxml = return xmlDoc.xml;
Sergey Alexandrovich Kryukov at 30-Apr-13 17:53pm
   
IE cannot be used for creating of any nodes (I'm not talking about JavaScrip running under IE). IE does not create anything at all. What are you talking about?
—SA
devcode007 at 1-May-13 9:40am
   
I am talking about javascript running under IE10 vs running under IE9. When i say IE10 created I meant running this given code under IE 10 browser
Sergey Alexandrovich Kryukov at 1-May-13 10:26am
   
Thanks goodness; now I understand it. Sorry, by some reason I thought it was external code. Looks weird...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100