Flash and XML Required

Hi there…

I’ve been using Flash for a while now but have just started using Flash Combined with XML.

I’m trying to make a poll system in flash which grabs data from a PHP generated xml file.

This is the contents of the xml file at the moment.

<?xml version=“1.0” ?>
- <poll>
<pollid id=“1” />

&lt;question text="**Do you surf or skate or both?**" /&gt; 

&lt;answer value="**Surf**"  answerid="**1**" /&gt; 

&lt;answer value="**Skate**"  answerid="**2**" /&gt; 

&lt;answer value="**Both**"  answerid="**3**" /&gt; 

</poll>

Now I’ve managed to load all of the data into flash using the following action script:
myXML = new XML();
myXML.ignoreWhite = true
myXML.onLoad = myOnLoad;
myXML.load(“poll.xml”);
function myOnLoad(success) {
if(success) {
trace(“XML loaded succesfully”);
processXML();
} else {
trace(“Error - Could not load XML file”);
}
}
function processXML() {
// Decalare variables
pollId = myXML.firstChild.firstChild.attributes.id;
pollIdName = myXML.firstChild.firstChild.nodeName;
question = myXML.firstChild.firstChild.nextSibling.attributes.text;
questionId = myXML.firstChild.firstChild.nextSibling.nodeName

     // Load variable valuables in
     trace("Poll ID Node Name: "+pollIdName);
     trace("Poll ID: "+pollId);
     trace("Question ID Node Name: "+questionId);
     trace("Question: "+question);
     
     //Load in Answers and answer ID's
     xmlLoop = myXML.firstChild.firstChild.nextSibling.nextSibling;
     while(xmlLoop.nodeName eq "answer") {
         trace("Answer No."+xmlLoop.attributes.answerid+" "+ xmlLoop.attributes.value + ". Answer ID = " + xmlLoop.attributes.answerid);
         xmlLoop = xmlLoop.nextSibling;
     }
 }

This produces the following output in flash:-
XML loaded succesfully
Poll ID Node Name: pollid
Poll ID: 1
Question ID Node Name: question
Question: Do you surf or skate or both?
Answer No.1 Surf. Answer ID = 1
Answer No.2 Skate. Answer ID = 2
Answer No.3 Both. Answer ID = 3

What I would like to do is load the answers into their own variable to display them in flash. I could do it if there was only ever going to be 3 questions to each answer but the number of questions could be 3 or more.

Is there a way to create a variable for each answer regardless of how many answers are in each question. I was thinking an array but I’m not sure of how to actually code it properly

Any help would be greatly appreciated.

The Jester