views:

256

answers:

1

In Flex I want to create XML variable like this but parser complains about CDATA in publisher tag:

<mx:Script>
 <![CDATA[
  private var myXML:XML = <book>
    <name>AatII</name>
    <author>gacgtc</author>
    <pages>0</pages>
    <publisher><![CDATA[Journal name]]></publisher>
   </book>;
 ]]>
</mx:Script>

But this works fine:

<mx:XML id="myXML">
 <book>
 <name>AatII</name>
 <author>gacgtc</author>
 <pages>0</pages>
 <publisher><![CDATA[Journal name]]></publisher>
        </book>
</mx:XML>

How do I pass xml text with CDATA into XML variable being in MXML Script?

+2  A: 

See S.Lott post from http://stackoverflow.com/questions/223652/is-there-a-way-to-escape-a-cdata-end-token-in-xml/223773#223773 I think that might work for you.

Jon