What's the best way to compile an XML file directly into ActionScript?

You can assign an XML literal to a variable as such:

var novel:XML = <BOOK><TITLE>My Book</TITLE></BOOK>

But it would be much better to have the XML in an externally managed
file. I'd much prefer to do something like:

var novel:XML = {include "Books.xml";};

But this doesn't seem to be allowed.

I could load the XML file at runtime but then I'd have to deal with
the asynchronous nature of the loading and I'd have to handle any
runtime errors if there was a problem - yuck!

If I was working in MXML I'd be able to do something very elegant such
as using the compile-time tag <mx:XML id="MyBooks" source="books.xml"/>

So how do I include XML into ActionScript in a way that is as elegant
as it is for MXML?

Reply via email to