打开一个XML字符串转换成ActionScript中的对象转换成、字符串、对象、XML

2023-09-08 11:57:27 作者:进击的屌丝i

我是pretty的新AS,和我假设有一种方法可以做到这一点,我只是没有计算出来。基本上,我想使用返回XML服务也不管返回XML结构的对象。在.NET中我使用 XmlSerializer.Deserialize 类...是那里等同?

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?

我能找到的 SimpleXMLDe codeR ,但我似乎无法得到它的工作 - 它看起来也像它可能只与节点的工作吗?无论哪种方式,这些例子在那里有稀疏,难以遵循,我只是想知道如何利用XML这样的:

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.

推荐答案

您可以使用 的HTTPService

You can use the HTTPService

有一个很好的例子,在这里...

There's a good example here...

的http://blog.flexexamples.com/2007/07/27/loading-xml-at-run-time-using-the-mxhttpservice-tag/ 这里的http://colourgray.word$p$pss.com/2008/08/08/flex-processing-xml-response-from-httpservice/ http://blog.flexexamples.com/2007/07/27/loading-xml-at-run-time-using-the-mxhttpservice-tag/ and here http://colourgray.wordpress.com/2008/08/08/flex-processing-xml-response-from-httpservice/

基本上,它会在您检索的结果序列化为XML从一个对象。

Basically it will serialize the result into an object from XML when you retrieve it.