如何从 Actionscript Arraycollection 读取 XML 属性?

发布于 2024-10-18 13:57:02 字数 477 浏览 3 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海夜未眠 2024-10-25 13:57:02

代码:

graphData = new ArrayCollection([event.result.data.readings])

只是创建一个包含一个值的 AC,该值将是一个 XMLList。我不确定您为什么要这样做,但这可能不是您的初衷。做这样的事情:

var graphData:XMLList = event.result.data.readings;
// Now get data for individual readings
trace("time for first reading", graphData[0].@time);
trace("time for second reading", graphData[1].@time);

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:

var graphData:XMLList = event.result.data.readings;
// Now get data for individual readings
trace("time for first reading", graphData[0].@time);
trace("time for second reading", graphData[1].@time);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文