A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Robust solution to illegal XML characters PHP/AS

  1. #1
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469

    Robust solution to illegal XML characters PHP/AS

    It's a common question how to encode illegal XML characters such as <, > inside XML. And the experts always tell us to enclose them inside CDATA...

    Actionscript Code:
    <mytag>
    <![CDATA[
    some illegal < > characters.
    ]]>
    </mytag>

    But is that the whole story? What if the string enclosed by CDATA contained the ]]> characters? What if I inserted some XML of my own? This would confuse the E4X parser, wouldn't it?

    My particular situation is generating XML in PHP, and parsing it in actionscript. Is there a convention to encoding the sting contained within CDATA... and if so, why don't we just encode and decode to replace illegal XML characters... why do we use CDATA at all?

    Or have I got it wrong?
    AIR, ActionScript 3, Flex and Flash expert and freelance developer

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Location
    San Diego, CA
    Posts
    13
    If you wanted to use the string "]]>" inside of CDATA then you should write the characters in HTML code.

    Here is a list of some of these special HTML characters: http://www.tedmontgomery.com/tutorial/htmlchrc.html

    If you used XML tags inside of CDATA it will just be rendered out as a string.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center