Ken
Ken

Reputation: 613

Better way to escape braces in E4X?

I have some XML I'm generating with {} characters, which are of course used for substitution.

It's hard to find any info on this: MDC is usually great documentation, but it doesn't mention anything about how to put brace literals in an E4X expression.

I finally found someone who had an answer: escape { } as { }. But it's really awkward to use. Is there any other way?

Upvotes: 0

Views: 329

Answers (1)

Chris Burt-Brown
Chris Burt-Brown

Reputation: 2727

Perhaps the cleanest method I can see is to substitute the braces in!

var text:String = "some {text} with {braces}";
var xml:XML = <something>{text}</something>;

Upvotes: 1

Related Questions