Friday, June 25, 2010

Accessing attributes in XML data passed as ArrayCollection

Hi,
If I have an XML list like this :

<?xml version="1.0"?>
<catalog>
 <clip desc="desc1">
 <title>check</title>
 </clip>
 <clip desc="desc2">
 <title>check2</title>
 </clip>
</catalog>

and I want to use it as a dataprovider to some tilelist, like this :
photoFeed = event.result.catalog.clip as ArrayCollection;

Then, if I want to access the attribute "desc" of clip,(inside
the datarenderer)
how do I do it?

<mx:TextArea text=????>
if I wanted the <title> part,
I could have done text="{data.title}"
but, what for the attribute "desc"?
Why is there no documentation for this?

I can do the following inside some actionscript code :
t.text = data["desc"];

but how do I do it inside mxml?

I also want to know, what actually happens, when
some XML data is passed as ArrayCollection to a
datarenderer? How does the ArrayCollection look like
if the input XML has child nodes(which may again
have attributes) and attributes
converted to the arraycollection.

Ans : 
Is there a reason you aren't using an XMLListCollection?  It would seem like a better fit.  As far as getting to the desc attribute you'd do data.clip.@desc.  Nothing more complicated than that.

No comments:

Blog Archive