How to read XML atributes from Actionscript Arraycollection?
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, rat开发者_如何学JAVAher 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?
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);
精彩评论