3 Replies Latest reply on Jan 14, 2007 9:48 AM by FlightGuy

    cdata in cdata

    Camus Miu Level 1
      can we use CDATA in declaration of XML in Actionscript?
      like, make the <xml2>hihi</xml2> in <info> node as CDATA???

      I got this error in mine:
      The element type "mx:Script" must be terminated by the matching end-tag "</mx:Script>".

      <?xml version="1.0" encoding="utf-8" ?>
      - <Script>
      - <![CDATA[
      var xml:XML = <ConceptNote>
      <title>Family - Sample</title>
      <xml2>hihi</xml2> <---------- MAKE IT CDATA... but I fail cuz can't put CDATA in CDATA

        • 1. Re: cdata in cdata
          FlightGuy Level 1
          The xml standard has no support for nesting of CDATA sections and, as far as I can tell, there is no way to escape the ]]> inside a CDATA section (no other markup is parsed).

          Try putting your xml variable definition into an AS class, rather than in your inline script node. There's a recent posting on this forum on the topic - had to do with using '}' inside the xml literal. That has some more detail on how to do it.

          • 2. Re: cdata in cdata
            Camus Miu Level 1
            so we just can't use CDATA in MXML...? =(
            • 3. Re: cdata in cdata
              FlightGuy Level 1
              You can use CDATA in MXML - you can't use nested CDATA in XML - any xml, and that includes MXML.

              If you don't use CDATA for your script block (I don't recommend this because you need to escape all markup, including your embedded xml literal), then you can use CDATA inside your xml literal. So, you can do this:

              var xml:XML = &lt;ConceptNote&gt;

              That's not easy to read, but there's your CDATA.

              If you put your literal in an .as class, then you don't have the nesting problem.