# Adding text from XML using for loop

**URL:** <https://forum.kirupa.com/t/adding-text-from-xml-using-for-loop/272091>\
**Category:** flash\
**Created:** [October 1, 2008, 11:01pm UTC](https://forum.kirupa.com/t/adding-text-from-xml-using-for-loop/272091 "2008-10-01T23:01:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rundevo](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@Rundevo](https://forum.kirupa.com/u/Rundevo)\
**Post date:** [October 1, 2008, 11:01pm UTC](https://forum.kirupa.com/t/adding-text-from-xml-using-for-loop/272091/1 "2008-10-01T23:01:10Z")

</div>

Can´t seem to add all the \<name\>gallery name \</name\> that I have in my XML.  
I only end up adding the one with the last iteration of [l].

Obviously I´m doing something wrong, and I´m not that good with for loops, so I´m really hoping that someone with better knowledge than me can help me out with this!

```auto
function loadwork(event:Event):void
	{
		workList = xml.item.name;

		workMenu.defaultTextFormat = myFormat;
		workMenu.wordWrap = true;
		workMenu.mouseEnabled = false;

		for (var l:int=0; l < workList.length(); l++)
		{
			workMenu.x = 10;
			workMenu.y = l * 30 + 240;
			workMenu.text = workList[l];
		}
		addChild(workMenu);
	}

```

That´s how far I´ve come using tutorials, going crazy now 🙂

Anyways, thanks in advance to any and all help in this matter!

Regards

/rundevo
