# XML: cycle through variable number of attributes. Any ideas?

**URL:** <https://forum.kirupa.com/t/xml-cycle-through-variable-number-of-attributes-any-ideas/298691>\
**Category:** flash\
**Created:** [October 23, 2009, 4:16am UTC](https://forum.kirupa.com/t/xml-cycle-through-variable-number-of-attributes-any-ideas/298691 "2009-10-23T04:16:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [October 23, 2009, 4:16am UTC](https://forum.kirupa.com/t/xml-cycle-through-variable-number-of-attributes-any-ideas/298691/1 "2009-10-23T04:16:36Z")

</div>

EDIT - worked it out But **Krilnon** had better solution.

Hi,

I have some data stored in an XML. The XML node has an unknown number of attributes. I want to cycle through the attributes and add them to an array. All suggestions or ideas are very welcome!!

my current thoughts are to have somthing like this  
XML:

```auto
<X>
<O V0="xxx"V1="aaa"V2="bbb"V3="ccc"></O>
</X>

```

then

```auto
var xd:XML = new XML();
//load the xml into the xd as usual then

for(var i:uint = 0; i < 100; i++)
{
     var attribute:String = 'V'+String(i);
	 var nodeData:String = xd.O.@[attribute] // fixed this line and now works
       if(nodeData == "") break;
	 myArray.push(nodeData)
}

```

Thank you for your help!

S.
