# Randomly receive a value from XML

**URL:** <https://forum.kirupa.com/t/randomly-receive-a-value-from-xml/326480>\
**Category:** flash\
**Created:** [December 17, 2011, 11:27am UTC](https://forum.kirupa.com/t/randomly-receive-a-value-from-xml/326480 "2011-12-17T11:27:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MFRS](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@MFRS](https://forum.kirupa.com/u/MFRS)\
**Post date:** [December 17, 2011, 11:27am UTC](https://forum.kirupa.com/t/randomly-receive-a-value-from-xml/326480/1 "2011-12-17T11:27:27Z")

</div>

I have the following XML

```auto
<countries>
                 <country>
                       <name>foo</name>
                       <phrase1>foo2</phrase1>
                       <phrase2>foo3 </phrase2>
                       <phrase3>foo4</phrase3>
                </country>
          </countries>

```

And i have a system that generates 40 stars, and each of those stars i want to have a information on them ( 1 have 40 countries in my xml, and 40 generated stars in the flash).

I have the following to randomly get a country name:

```auto

var countries:Array = new Array();

for (var est:int = 0;est < 40; est++) {
countries = [];

    var ps:int = (Math.floor(Math.random()*countries.length));
    countries.push(myXML.country.name[ps]);

```

But i can’t get a random number from there. Any ideas?
