download Original_Quiz.zip (the starter files)

Let's begin with the XML file. I'm just going to use the same silly questions and answers that I made up previously, except that I added one more so that there are five questions altogether.

Notice that each item in this file has the same basic structure. There is a question, an answer (the digit that represents the correct answer), and any number of choices. This is the same basic structure that we formerly used in the quiz program, so adapting it shouldn't be very much hassle at all.

Make sure this file is in the same folder as your other quiz files. If you don't have the other quiz files, they're available from the link at the top of this page. The XML file is included in the zip. But if you didn't download it from the link above, you can copy and paste it into a text editor and save it as "quiz.xml." And here it is:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<item>
<question>What color is an orange?</question>
<answer>2</answer>
<choice>Orange</choice>
<choice>Blue</choice>
<choice>Purple</choice>
<choice>Brown</choice>
</item>
<item>
<question>What is the shape of planet earth?</question>
<answer>3</answer>
<choice>Flat</choice>
<choice>Cube</choice>
<choice>Round</choice>
<choice>Shabby</choice>
</item>
<item>
<question>Who created SpiderMan?</question>
<answer>2</answer>
<choice>Jack Kirby</choice>
<choice>Stan Lee and Steve Ditko</choice>
<choice>Stan Lee</choice>
<choice>Steve Ditko</choice>
<choice>none of the above</choice>
</item>
<item>
<question>Who created Mad?</question>
<answer>2</answer>
<choice>Al Feldstein</choice>
<choice>William M. Gaines</choice>
<choice>Jack Davis</choice>
<choice>none of the above</choice>
</item>
<item>
<question>Who was our first President?</question>
<answer>1</answer>
<choice>George Washington</choice>
<choice>John Adams</choice>
<choice>Jack Daniels</choice>
<choice>Skeeter Davis</choice>
</item>
</data>

We're only going to work on two files: QuizApp.as and QuizQuestion.as. We're going to make the QuizApp get its data from the XML file, and we're going to make QuizQuestion.as receive an XML object as a parameter instead of the three parameters it gets now. Ready?

P.S. I just realized that the last question I threw in there is kind of US-centric, and this is the Internet. So if you are not in the United States, feel free to change that one to whatever it would be for your country. In fact, change any or all of the questions and make it your quiz!