# Building XML quiz: cant populate the childNodes to the text fields

**URL:** <https://forum.kirupa.com/t/building-xml-quiz-cant-populate-the-childnodes-to-the-text-fields/209980>\
**Category:** flash\
**Created:** [December 13, 2006, 9:19pm UTC](https://forum.kirupa.com/t/building-xml-quiz-cant-populate-the-childnodes-to-the-text-fields/209980 "2006-12-13T21:19:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![orlando2004](https://avatars.discourse-cdn.com/v4/letter/o/b5ac83/32.png) [@orlando2004](https://forum.kirupa.com/u/orlando2004)\
**Post date:** [December 13, 2006, 9:19pm UTC](https://forum.kirupa.com/t/building-xml-quiz-cant-populate-the-childnodes-to-the-text-fields/209980/1 "2006-12-13T21:19:16Z")

</div>

I couldnt find a tutorial on building an XML-based quiz so I am posting here. In my timeline, there is a frame for each question in my XML file. Each frame also has a blank dynamic text field. So far, using trace I have been able to see my question-answer pairs extracted from the XML file but no luck at populating the actual fields.

Here is an example of my XML:

\<?xml version=“1.0” encoding=“iso-8859-1”?\>  
\<quiz\>  
\<item question = “There is a sport for every body shape and a body shape for every sport.” answer = “true” /\>  
\<item question = “It is normal for an athlete’s menstrual periods to stop or not start at all.” answer = “false” /\>  
\</quiz\>

Here is the code I currently have on Frame 1 of my timeline (which only gets me as far as trace and perhaps storing something in the vars):

var myXMLQuestions:XML = new XML();  
myXMLQuestions.ignoreWhite = true;  
myXMLQuestions.onLoad = function(bSuccess:Boolean):Void {  
if (bSuccess) {  
// NOTE: I am using attributes in my XML document  
var xnRoot:XMLNode = this.firstChild //this will hold the root node in the XML file  
var xnItem:XMLNode; //this will hold the question-answer pairs in XML file (used in the for loop and array)  
for(var i:Number = 0; i \< xnRoot.childNodes.length; i++) {  
xnItem = xnRoot.childNodes\*;  
//trace(xnItem.attributes.question); //this will show the question attribute in the XML file  
var sQuestion:String = xnItem.attributes.question; //NEW LINE  
//trace(xnItem.attributes.answer); //this will show the answer attribute in the XML file  
var sAnswer:String = xnItem.attributes.answer; //NEW LINE  
q1\_txt.text = sQuestion; //Text field supposed to hold first question  
}  
//initXML(); //Process XML by sending to parsing function  
}  
};

Can anyone please provide guidance?
