# Get data from Xml problem

**URL:** https://forum.kirupa.com/t/get-data-from-xml-problem/182502
**Category:** programming
**Created:** [March 18, 2006, 10:11pm UTC](https://forum.kirupa.com/t/get-data-from-xml-problem/182502 "2006-03-18T22:11:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![W84me](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/w84me/32/1257_2.png) [@W84me](https://forum.kirupa.com/u/W84me)
#### Post date: [March 18, 2006, 10:11pm UTC](https://forum.kirupa.com/t/get-data-from-xml-problem/182502/1 "2006-03-18T22:11:39Z")

</div>

Hi all!

I have this problem:

I have this xml file

```auto
<audio id="1" media="cd">
  <title>Example 1</title>
  <location>A1</location>
  <songs>
   <song num="1" name="example1" file="" />
   <song num="2" name="example2" file="" />
  </songs>
 </audio>

```

And i want to get all the songs from the songs element with this function:

```auto
function processXMLData(success) {
    if (success) {
        var list = this.firstChild.childNodes[2].childNodes;
        for (var i = 0; i<list.length; i++) {
            songs = list*.attributes.name;
            trace(songs);
        }
    } else {
        songs = "no audio file found!";
    }
}
var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = processXMLData;
xmlData.load("xmlsmall.xml");
stop();

```

I create a dymanic text field with the variable songs but when i test it it displays only the last song…

Any ideas?:sigh:

---

<div class="post-metadata">

### Author: ![KyoKusanagi](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@KyoKusanagi](https://forum.kirupa.com/u/KyoKusanagi)
#### Post date: [March 19, 2006, 3:53am UTC](https://forum.kirupa.com/t/get-data-from-xml-problem/182502/2 "2006-03-19T03:53:43Z")

</div>

```auto

var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function (success) {
    if (success) {
        var list = this.firstChild.childNodes[2].childNodes;
        for (var i = 0; i<list.length; i++) {
            _root.myTextBox.text [U] **+=** [/U] list*.attributes.name + "
";
        }
    } else {
        _root.myTextBox.text = "no audio file found!";
    }
};
xmlData.load("xmlsmall.xml");
stop();

```

---

<div class="post-metadata">

### Author: ![W84me](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/w84me/32/1257_2.png) [@W84me](https://forum.kirupa.com/u/W84me)
#### Post date: [March 19, 2006, 2:21pm UTC](https://forum.kirupa.com/t/get-data-from-xml-problem/182502/3 "2006-03-19T14:21:39Z")

</div>

Thanks a lot! 🙂 I knew it wasnt so difficult but i couldnt imagine the way… 😏
