I have created two arrays from XML the first array (QuestionArray) contains the second array (AnswersArray). The answers to each question in the XML are:
Question 1
-True
-False
Question 2
-Hartford
-Bloomfield
-New Haven
-Washington D.C
But when I trace the answers in my array I get:
True, False
Washington D.C, Bloomfield, New Haven, Washington D.C
Here’s my code:
function buildQuestionArray() {
_global.QuestionsArray = new Array ()
for (var i=0; i<TestNode.childNodes.length; i++){
curQuestion=TestNode.childNodes*;
var AnswersArray = new Array();
for (var j=0; j<curQuestion.childNodes.length; j++){
curParts=curQuestion.childNodes[j];
for (var b=0; b<curParts.childNodes.length; b++){
if (curParts.childNodes**.nodeName==null){
curImage=curParts.childNodes**;
}else if (curParts.childNodes**.nodeName!=null){
curImage=null;
curAnswers=curParts.childNodes**;
}
AnswersArray**= curAnswers.childNodes
}
}
_global.QuestionsArray* = new Question (curQuestion.attributes.number, curQuestion.attributes.format, curQuestion.attributes.correctanswer, curQuestion.attributes.text, curImage, AnswersArray)
}
makeQuestion (currentQuestion);
ClickTrue (currentQuestion);
}
function Question (numbers, format, correct, Text, Image, Answers) {
this.numbers=numbers
this.correct=correct
this.Text=Text
this.format=format
this.Image=Image
this.Answers=Answers
trace (Answers)
}
[/QUOTE]