I am pretty new to AS, and I am assuming there is a way to do this and I am just not figuring it out. Basically, I am trying to use a service that returns xml and return an Object regardless of the structure of the xml. In .Net I use the XmlSerializer.Deserialize class... is there equivalent in AS?
I was able to find SimpleXMLDecoder but I can't seem to get it to work - it also looks like it might only work with nodes? Either way, the examples out there are sparse and hard to follow, I just want to know how to take xml like this:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Company>
<Id>2</Id>
<Name>Stan</Name>
<Size>10</Size>
</Company>;
And simply turn it into an Object - is this possible without writing my own parser? Thank you.
ActionScript has its own
XML
parser then you don't need to write yours.XML from a String
If you have a
String
to convert, you can just convert it asXML
inline with few lines of code like this:XML from an external file
Otherwise you can just load it in runtime in this way:
Edited with links
Some nice links to start working:
The Basic
http://blog.theflashblog.com/?p=242
Some nice E4X tips and how-to
http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4
Hope this helps. Ciao!
You can use the
HTTPService
There's a good example here...
Basically it will serialize the result into an object from XML when you retrieve it.