You could do the same using an associative array (Object/Hashtable). Iterate through the data one time, using bracket notation to create the properties. You can't iterate in order over this structure, if that matters.
Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Sutherland Sent: Thursday, August 21, 2008 11:58 AM To: [email protected] Subject: RE: [flexcoders] XML Data - getting unique attributes You could do something like the following. Use a dictionary to store you're unique values. So iterate through your data and use the data as the key for the dictionary Var myDictionary : Dictionary = new Dictionary(); myDictionary[value] = value; //value would be whatever you are wishing to store, should you iterate through a dataset and have more than one value which is the same then it will end up only being stored once. //then you could pass it all into an ArrayCollection so that you could bind to that data or similar. public function getUniqueValues (val : Dictionary) : ArrayCollection { var unique = new ArrayCollection(); for(var prop :String in val){ unique.addItem(val[prop]); } } Hope that's what your after. If you have a very large dataset then you don't need to do any checking if it already exists in the dictionary, so I'm presuming it will be reasonably efficient. Kenneth. From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of sdl1326 Sent: 21 August 2008 15:06 To: [email protected] Subject: [flexcoders] XML Data - getting unique attributes Hello All, I need to grab all unique attribute values in some xml data. Is there a quick and dirty way to do this? I could push to an array if the value doesn't already exist, however I did not know if there was a more efficient way to get these values. Example: <data> <projects name="Project A" /> <projects name="Project B" /> <projects name="Project C" /> <projects name="Project A" /> </data> Unique values would be: Project A, Project B, Project C Thanks for any and all replies. Disclaimer ________________________________ This electronic message contains information which may be privileged and confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone on 0131 476 6000 and delete the material from your computer. Registered in Scotland number: SC 172507. Registered office address: Quay House 142 Commercial Street Edinburgh EH6 6LB. This email message has been scanned for viruses by Mimecast. ________________________________

