# XMLList "for each" loop update

**URL:** <https://forum.kirupa.com/t/xmllist-for-each-loop-update/322717>\
**Category:** flash\
**Created:** [May 31, 2011, 3:24pm UTC](https://forum.kirupa.com/t/xmllist-for-each-loop-update/322717 "2011-05-31T15:24:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashgroove](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@flashgroove](https://forum.kirupa.com/u/flashgroove)\
**Post date:** [May 31, 2011, 3:24pm UTC](https://forum.kirupa.com/t/xmllist-for-each-loop-update/322717/1 "2011-05-31T15:24:36Z")

</div>

I have a problem with updating an XMLList object while in a “for each” loop.

I have the following XMLList object called “folders”:

```auto

<folders>
	<folder1>folder1</folder1>
	<folder2>folder2</folder2>
	<folder3>folder3</folder3>
	<folder4>folder4</folder4>
	<folder5>folder5</folder5>
</folders>

```

And I am running the following code:

```auto

var item:XML;
			
for each(item in folders.*)
{
	if (item.toString() != "")
	{
		item = XML(item.toString() + "/");
	}
	trace(item);
}

trace(folders);

```

And the results that are tracing to the Output panel are the following:

```auto

folder1/
folder2/
folder3/
folder4/
folder5/
<folders>
	<folder1>folder1</folder1>
	<folder2>folder2</folder2>
	<folder3>folder3</folder3>
	<folder4>folder4</folder4>
	<folder5>folder5</folder5>
</folders>

```

Basically, the individual XML objects are updating but they are not updating in the “folders” XMLList object.

What can i do to update them in the “folders” object ?

I have used a similar approach to update all of the attributes of an XMLList object and everything worked ok. I am not sure what exactly causes the differences between the attributes and the elements.
