0 Replies Latest reply on Nov 5, 2009 2:37 PM by jmandawg

    Bug adding CDATA element into XML object

    jmandawg Level 1

      When i add  CDATA  to a flex XML object, i lose the <element></element> tags.  Is this a bug??  Here is example code for doing this Just press the "Add CDATA" button:

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" initialize="init()">
         
          <mx:Script>
              <![CDATA[
                 
                  [Bindable]
                  var myData:String;
                 
                  var myXML:XML = <test></test>
                                     
                  function init()
                  {
                      myXML.testData = "HELLO JOHN";
                      myData = myXML.toXMLString();
                  }
                  function addCDATA(event:Event):void
                  {
                     
                      myXML.testData = new XML("<![CDATA[HELLO JOHN CDATA]" + "]>");
                      myData = myXML.toXMLString();
                  }
                  function addDATA(event:Event):void
                  {
                     
                      myXML.testData = new XML("HELLO JOHN");
                      myData = myXML.toXMLString();
                  }
              ]]>
          </mx:Script>
          <mx:TextArea text="{myData}" width="100%" height="100%" />
          <mx:HBox>
              <mx:Button label="Add Regular Data" click="{addDATA(event);}" />
              <mx:Button label="Add CDATA" click="{addCDATA(event);}" />
          </mx:HBox>
      </mx:Application>