PLEASE HELP! XML is making me INSANE!

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!

Here is the AS:
function loadXML(loaded) {
if (loaded) {
_root.press = 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”?>
<press>
<article>
<caption>This is the first article</caption>
<URL>http://www.google.com</URL>
</article>
<article>
<caption>This is the second article</caption>
<link>http://www.google.com</link>
</article>
</pres
s>

Does that help?

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

In case anybody cares…:crazy:

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:


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");


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

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?

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.

I’ll try it now. Thanks.

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…

Files attached…


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*+" ";
    }
}

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!

quasi code:


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

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!