Skip to content

Instantly share code, notes, and snippets.

@minodisk
Created August 20, 2011 11:27
Show Gist options
  • Save minodisk/1158984 to your computer and use it in GitHub Desktop.
Save minodisk/1158984 to your computer and use it in GitHub Desktop.
XMLリテラルでCDATA
var text:String = 'abc0123456789';
var a:XML = <a><![CDATA[{text}]]></a>;
trace(a.toXMLString()); // <a><![CDATA[{text}]]></a>;
var b:XML = <b>{'<![CDATA[' + text + ']]>'}</b>;
trace(b.toXMLString()); // <b>&lt;![CDATA[abc0123456789]]&gt;</b>
var c:XML = <c>{new XML('<![CDATA[' + text + ']]>')}</c>;
trace(c.toXMLString()); // <c><![CDATA[abc0123456789]]></c>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment