# PLEASE HELP! XML is making me INSANE!

**URL:** <https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724>\
**Category:** Uncategorized\
**Created:** [April 24, 2006, 3:56am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724 "2006-04-24T03:56:25Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 3:56am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/1 "2006-04-24T03:56:25Z")

</div>

I’ve searched and searched what feels like THE ENTIRE INTERNET until I can’t see anymore!

Here’s what I want to do and I’d love it if somebody could just give me a little advice…I’ve followed the xml tutorial on kirupa, but still can’t figure out how to do what I want to do! Please help me!

Here’s what I need to do:

External XML file holds all the data for each person, right? All their accomplishments, their bio, their phone number, etc.

Buttons correspond to data - “Accomplishments” “bio” “phone numbers” right?

On press of each button, I simply want to populate my dynamic text box with ALL the data of a certain kind for each person. That is to say, ALL the accomplishments. Then the bio. Then ALL the phone numbers.

That’s it.

How can I do this? I’ve searched and searched and everything seems so complicated. Anybody have a SIMPLE solution to this?

Please help. I’m desperate.

Thank you!

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:07am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/2 "2006-04-24T04:07:44Z")

</div>

Here is the AS:  
function loadXML(loaded) {  
if (loaded) {  
\_root.pres**s = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;  
\_root.article = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;  
textfile\_txt.text = \_root.pres**s;  
textfile2\_txt.text = \_root.article;  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“eba.xml”);

Here is the XML File:  
\<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
\<pres**s\>  
\<article\>  
\<caption\>This is the first article\</caption\>  
\<URL\>[http://www.google.com](http://www.google.com)\</URL\>  
\</article\>  
\<article\>  
\<caption\>This is the second article\</caption\>  
\<link\>[http://www.google.com](http://www.google.com)\</link\>  
\</article\>  
\</pres**s\>

Does that help?

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:08am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/3 "2006-04-24T04:08:47Z")

</div>

Hey, look at that, the forum thinks I’m cussing! It says “Press Hits” only without the space…

In case anybody cares…:crazy:

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 24, 2006, 4:10am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/4 "2006-04-24T04:10:33Z")

</div>

[www.gotoAndLearn.com](http://www.gotoAndLearn.com)

thier tuts are down, but they should be back up soon.

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:20am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/5 "2006-04-24T04:20:57Z")

</div>

> [@foomonkey10](#):
>
> [www.gotoAndLearn.com](http://www.gotoAndLearn.com)
> 
> thier tuts are down, but they should be back up soon.

Hi there!

Thanks so much for responding. I went there already, and looked at the XML tutorial (for displaying video clips) but this isn’t what I mean at all.

That uses a component, and I just simply want to display all the data of each kind in my dynamic text box. With what I have, I only get the first “article”. Why not all of them? Any suggestions? I promised, I’ve looked VERY thoroughly for the answer to my problem.

:te:

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 24, 2006, 4:25am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/6 "2006-04-24T04:25:41Z")

</div>

```auto

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
    var animals:Array = xml.firstChild.childNodes;
    type = [];
    sound = [];
    fur = [];
    size = [];
    for (i=0; i<animals.length; i++) {
        type* = animals*.attributes.type;
        sound* = animals*.attributes.sound;
        fur* = animals*.attributes.fur;
        size* = animals*.attributes.size;
        //trace("t = "+type*+" s = "+sound*+" f = "+fur*+" sz = "+size*);
        trace( typeof( type* ) );
        trace(" _______________");
    }
};
xml.load("animals.xml");

```

```php

<master>
   <node type="lion" sound="roar" fur="coarse" size="large" />
   <node type="dog" sound="bark" fur="soft" size="medium" />
</master>

```

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 24, 2006, 4:27am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/7 "2006-04-24T04:27:12Z")

</div>

use that code and add in the for loop

\_txt.text += // whatever attibute you want.

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:43am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/8 "2006-04-24T04:43:35Z")

</div>

> [@foomonkey10](#):
>
> use that code and add in the for loop
> 
> \_txt.text += // whatever attibute you want.

Sorry, bear with me. I’m not using any PHP.

What loop?

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:44am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/9 "2006-04-24T04:44:53Z")

</div>

I can’t do this with just AS and XML? Confused.

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 24, 2006, 4:48am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/10 "2006-04-24T04:48:14Z")

</div>

> [@beanpie](#):
>
> I can’t do this with just AS and XML? Confused.

I simply put a tag to format the example xml, it isn’t php. Play around with the example for 30 minutes, (it parses nicer than yours), and see if you can get it to work for you. If not, zip up your files and attach them here.

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:48am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/11 "2006-04-24T04:48:51Z")

</div>

I’ll try it now. Thanks.

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:52am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/12 "2006-04-24T04:52:38Z")

</div>

One last thing. I’m sorry to be dense. I see that yours is nice and smooth. But how do I display the array in my dynamic text box? I just want all the animals to show up in a row…

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 4:59am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/13 "2006-04-24T04:59:52Z")

</div>

Files attached…

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 24, 2006, 6:48am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/14 "2006-04-24T06:48:00Z")

</div>

```auto

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
    var animals:Array = xml.firstChild.childNodes;
    type = [];
    sound = [];
    fur = [];
    size = [];
    for (i=0; i<animals.length; i++) {
        type* = animals*.attributes.type;
        sound* = animals*.attributes.sound;
        fur* = animals*.attributes.fur;
        size* = animals*.attributes.size;
        //trace("t = "+type*+" s = "+sound*+" f = "+fur*+" sz = "+size*);
        trace(typeof (type*));
        trace(" _______________");
    }
    showAnimals();
};
xml.load("eba.xml");
//
// THIS SIMPLE LITTLE FUNCTION.
function showAnimals() {
    for (var i = 0; i<type.length; i++) {
        displayresults.text += type*+" ";
    }
}

```

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 24, 2006, 12:45pm UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/15 "2006-04-24T12:45:47Z")

</div>

Ah hah!

That’s great. and I finally get what I was missing all along.

It works fine but as I’ll have more than one button, I’ll need to “unload” the type of animal and replace it with the attirbutes of the animal when the attributes button is pushed.

How does this happen? Is this a “listener”? (I still haven’t figured out quite what a listener is supposed to do…)

Can you point me in the right direction for this?

Thanks!

---

<div class="post-metadata">

**Author:** ![foomonkey10](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@foomonkey10](https://forum.kirupa.com/u/foomonkey10)\
**Post date:** [April 25, 2006, 2:11am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/16 "2006-04-25T02:11:21Z")

</div>

quasi code:

```auto

_btn.onRelease = function() {
   _txt.text = "";
   // same principle as before
}

```

---

<div class="post-metadata">

**Author:** ![beanpie](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@beanpie](https://forum.kirupa.com/u/beanpie)\
**Post date:** [April 25, 2006, 2:40am UTC](https://forum.kirupa.com/t/please-help-xml-is-making-me-insane/186724/17 "2006-04-25T02:40:43Z")

</div>

Thanks. I gave that a try before, but it doesn’t seem to replace the data with new data when you press the next button. I’ve got several buttons, as per the fla. I feel a little dense at this point…

For some reason this seems like it must be a simple thing, but I can’t seem to manage it. Arrgh.

Thanks for all your help!
