E4X: no > for you
January 22nd, 2010In E4X (for actionscript 3), the “greater than” symbol is not always XML encoded as “>”. However, the “less than” symbol is encoded. While this looks odd, it’s actually valid according to the XML spec.
var bar:String="< wokka >";
var xml:XML = <foo value= {bar} > The value is unbalanced </foo>;
trace(xml.toXMLString());
/*
<foo value="< wokka >">The value is unbalanced</foo>
*/
http://www.w3.org/TR/REC-xml/
The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings ”
&” and ”<” respectively. The right angle bracket (>) may be represented using the string ”>“, and MUST, for compatibility, be escaped using either ”>” or a character reference when it appears in the string ”]]>” in content, when that string is not marking the end of a CDATA section.In the content of elements, character data is any string of characters which does not contain the start-delimiter of any markup and does not include the CDATA-section-close delimiter, ”
]]>“. In a CDATA section, character data is any string of characters not including the CDATA-section-close delimiter, ”]]>“.



