# Shuffle / randomizer for XML data

**URL:** <https://forum.kirupa.com/t/shuffle-randomizer-for-xml-data/330780>\
**Category:** flash\
**Created:** [March 14, 2013, 7:21pm UTC](https://forum.kirupa.com/t/shuffle-randomizer-for-xml-data/330780 "2013-03-14T19:21:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![red2034](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@red2034](https://forum.kirupa.com/u/red2034)\
**Post date:** [March 14, 2013, 7:21pm UTC](https://forum.kirupa.com/t/shuffle-randomizer-for-xml-data/330780/1 "2013-03-14T19:21:06Z")

</div>

I have a quiz set up pulling xml data in:  
\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<document\>  
\<intro\>\<b\>Introduction & Instructions\</b\>\</intro\>  
\<desc\>Description can go here\</desc\>

\<question\>question 1 would go here\</question\>  
\<answer\>question 1 answer1\</answer\>  
\<answer\>question 1 answer2\</answer\>  
\<answer\>question 1 answer3\</answer\>  
\<answer\>\*question 1 answer4\</answer\>  
\<remediation\>question 1 feedback/remediation\</remediation\>

…and so on for as many Qs as I have, and I am pulling them into flash using:  
var page\_xml = new XML();  
page\_xml.ignoreWhite = true;  
page\_xml.onLoad = function(success){  
if (success) {  
gsIntro = page\_xml.firstChild.childNodes[0].toString();  
gsDesc = page\_xml.firstChild.childNodes[1];

```
    gsQ1 = page_xml.firstChild.childNodes[2];
    gsQ1a = page_xml.firstChild.childNodes[3].toString();
    gsQ1b = page_xml.firstChild.childNodes[4].toString();
    gsQ1c = page_xml.firstChild.childNodes[5].toString();
    gsQ1d = page_xml.firstChild.childNodes[6].toString();
    gsQ1f = page_xml.firstChild.childNodes[7].toString();

```

//and so on

}else {  
trace(“Error loading XML file”);  
}  
}  
page\_xml.load(“quiz.xml”);

…then later in the timeline I am adding the imported xml into a text box with a Variable label \_root.gsQ1 and so on.

my question is will I need to restructure this to have the answers shuffle / randomize?

Or can I use a shuffle function that builds an array for each set of answers then uses the existing text boxes later in the timeline?
