Skip to content

Instantly share code, notes, and snippets.

@claus
Created June 28, 2010 22:17
Show Gist options
  • Save claus/456446 to your computer and use it in GitHub Desktop.
Save claus/456446 to your computer and use it in GitHub Desktop.
// ok i want a root <a> node that has two children: a <b> node and a random text node
// the random text node should be automatically escaped if appropriate:
// <a>
// <b/>
// a &lt; b
// </a>
var txt:String = "a < b";
var xml:XML = <a/>;
xml.appendChild(<b/>);
xml.appendChild(txt);
trace(xml.toXMLString());
// this creates an extra <b> element. BUG!
// <a>
// <b/>
// <b>a &lt; b</b>
// </a>
// the only workaround i found is this:
var txt:String = "a < b";
var xml:XML = <a/>;
xml.appendChild(<b/>);
xml.appendChild(<dummy>{txt}</dummy>.children()[0]);
trace(xml.toXMLString());
// <a>
// <b/>
// a &lt; b
// </a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment