打开一个XML字符串转换成ActionScript中的对象 [英] Turn an XML string into an Object in Actionscript

查看:118
本文介绍了打开一个XML字符串转换成ActionScript中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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.

推荐答案

您可以使用<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html"相对=nofollow> 的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/
  • 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.

这篇关于打开一个XML字符串转换成ActionScript中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆