# Xml & flash 8

**URL:** https://forum.kirupa.com/t/xml-flash-8/244750
**Category:** Uncategorized
**Created:** [November 21, 2007, 1:08pm UTC](https://forum.kirupa.com/t/xml-flash-8/244750 "2007-11-21T13:08:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sketchie](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sketchie](https://forum.kirupa.com/u/sketchie)
#### Post date: [November 21, 2007, 1:08pm UTC](https://forum.kirupa.com/t/xml-flash-8/244750/1 "2007-11-21T13:08:35Z")

</div>

Hi all,

I’ve got a little question regarding XML in Flash 8.

My XML file:

```auto

<?xml version="1.0" encoding="utf-8"?>

<objecten>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 1</content>
    </entry>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 2</content>
    </entry>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 3</content>
    </entry>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 4</content>
    </entry>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 5</content>
    </entry>
    <entry>
        <image>img/kaart.jpg</image>
        <content>tekst 6</content>
    </entry>
</objecten>

```

Is it possible that, when I click on a button, a specific childNode is loaded in my .swf?  
I think I’m almost there, 'cause I’ve put this on my first button:

```auto

on(release) {
    function loadXML(loaded) {
    if (loaded) {
        _root.img = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        _root.content = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        imgHolder.loadMovie(_root.img);
        txtStart.text = _root.content;
    } 
    else {
        trace("file not loaded!");
    }
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content.xml");
}

```

… and that works like a charm, but when I put the script on my second button & I make some changes like say

```auto

_root.img = this.firstChild.childNodes[0].childNodes[**2**].firstChild.nodeValue;
_root.content = this.firstChild.childNodes[0].childNodes[**3**].firstChild.nodeValue;

```

, I get an ‘undefined’ on the screen.

In a nutshell what I want is this:

- when clicked on button 1, tekst1 & img1 appear
- when clicked on button 2, tekst2 & img2 appear

Edit after 5 minutes or so:  
Okay, I’ve found the answer: instead of making the changes I tried above, you just have to change the first [0] into [1], [2], etc.  
You have to change it for all nodes; \_root.img & \_root.content in this case.  
The only thing I’m not entirely sure off is the usage of \_root. …
