PDA

View Full Version : Loaded XML content problem



spectator
August 26th, 2008, 05:22 PM
Hi all :) I am trying to load info from a xml file and then use it. I can load the info and store it into a XML or XMLList, but a problem appears after that. I have a xml with questions node and two nodes which are named part1 and part2. In both part1 and part2 there are questions nodes and options nodes. What I am trying to do is push question from part1 and part2 into a Array. I have this code
function ShowQuestions():void {
for (var i:Number=0; i < questions; i++) {
ArrayJoin = "xmlList.part" + (i+1) +".question.text()";
QuestArray.push(xmlList.part1.question.text());
QuestArray.push( "sasfasf");
trace(QuestArray);
trace (ArrayJoin);

} questions var shows me how many parts I have. I was trying to do something with the variable ArrayJoin and use it to show which part of the xmlList I want to push into the array. But when this variable is String it just adds the String to the array. Please help me. 10x in advance :)

Pier25
August 27th, 2008, 04:44 AM
With the new xml class you can access directly the data in your xml object. In as2 you could also do it but it was a pain... so you had to put the data in an array or an object to be able to use it.

What I mean is you don't need to put anything into an array, or an object. Your xml is already an "array".

http://www.sephiroth.it/tutorials/flashPHP/E4X/

That doesn't solve your problem... but maybe it will make things easier for future projects.

spectator
August 27th, 2008, 10:31 AM
10x for the answer :) I read the article you gave me and I realized that I should have part1 and part2 to part and then access them just by xmlList.part[i].question.text().

Pier25
August 27th, 2008, 10:40 AM
First time I used xml in as3 I was doing the same mistake... until I realized how powerful the new xml class is.

;)