如何从 Actionscript Arraycollection 读取 XML 属性?
我正在使用actionscript中的httpservice读取XML文件,并将其放入像这样的数组集合中(其中读数是重复节点,数据是根节点):
graphData = new ArrayCollection([event.result.data.readings]);
但是我想将正在读取的xml文件的格式更改为将值作为属性而不是标签之间的值放入(我这样做的原因是 xml 文件很大,并且此方法只需要一行,每次读取 5 个属性,而不是在单独的行上放置 5 个打开和关闭标签)。
它可以正常加载到数组集合中,但是如何访问属性? 在我访问时间值之前,请说如下:
graphData.getItemAt(0).time
所以我想这可能很简单:
graphData.getItemAt(0).@time
但这不起作用,可以吗?
I'm reading an XML file with the httpservice in actionscript, and putting it into an arraycollection like this (where readings is the repeating node and data is the root node):
graphData = new ArrayCollection([event.result.data.readings]);
However I want to change the format of the xml file im reading to put the values in as attributes instead of values between tags (the reason im doing this is the xml files where huge and this method would require just one line with 5 attributes per reading, rather than 5 open and closing tags on separate lines).
Its loading ok into the array collection, but how do I access the attributes?
Before I would access the time value say as follows:
graphData.getItemAt(0).time
so I figured it may be as easy as:
graphData.getItemAt(0).@time
but this doesnt work, can it be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码:
graphData = new ArrayCollection([event.result.data.readings])
只是创建一个包含一个值的 AC,该值将是一个 XMLList。我不确定您为什么要这样做,但这可能不是您的初衷。做这样的事情:
The code:
graphData = new ArrayCollection([event.result.data.readings])
Just creates an AC with one value in it, which will be an XMLList. I'm not sure why you'd want to do that, but it's probably not what you had in mind. Do something like this: