# Loading XML, need to be dynamic

**URL:** <https://forum.kirupa.com/t/loading-xml-need-to-be-dynamic/306665>\
**Category:** flash\
**Created:** [March 19, 2010, 2:08pm UTC](https://forum.kirupa.com/t/loading-xml-need-to-be-dynamic/306665 "2010-03-19T14:08:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chappo](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@Chappo](https://forum.kirupa.com/u/Chappo)\
**Post date:** [March 19, 2010, 2:08pm UTC](https://forum.kirupa.com/t/loading-xml-need-to-be-dynamic/306665/1 "2010-03-19T14:08:09Z")

</div>

Hi all,

Was wondering if someone could steer me into the right direction or shed a bit of light on my problem.

Current situation  
At the moment i am using the following code to display text from an external XML file

```auto
function loadXML(loaded) {
	if (loaded) {
		_root.textfields1 = this.firstChild.childNodes[0].firstChild.nodeValue;
		_root.textfields2 = this.firstChild.childNodes[1].firstChild.nodeValue;
		_root.textfields3 = this.firstChild.childNodes[2].firstChild.nodeValue;
		_root.textfields4 = this.firstChild.childNodes[3].firstChild.nodeValue;
		_root.textfields5 = this.firstChild.childNodes[4].firstChild.nodeValue;
		_root.textfields6 = this.firstChild.childNodes[5].firstChild.nodeValue;
		_root.textfields7 = this.firstChild.childNodes[6].firstChild.nodeValue;
		_root.textfields8 = this.firstChild.childNodes[7].firstChild.nodeValue;

		block01.text01.text = _root.textfields1;
		block02.text02.text = _root.textfields2;
		block03.text03.text = _root.textfields3;
		block04.text04.text = _root.textfields4;
		block05.text05.text = _root.textfields5;
		block06.text06.text = _root.textfields6;
		block07.text07.text = _root.textfields7;
		block08.text08.text = _root.textfields8;
	} else {
		content = "file not loaded!";
	}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("/flash/site_eng.xml");

var format:TextFormat = new TextFormat();
format.letterSpacing = -1;
block01.text01.setNewTextFormat(format);
block02.text02.setNewTextFormat(format);
block03.text03.setNewTextFormat(format);
block04.text04.setNewTextFormat(format);
block05.text05.setNewTextFormat(format);
block06.text06.setNewTextFormat(format);
block07.text07.setNewTextFormat(format);
block08.text08.setNewTextFormat(format);

```

The “site\_eng.xml” means that it loads in the english version of the XML file.  
The problem is that i need to make it dynamic so that it can look at a different XML file in a different map - this is because i need to direct it to 6 different language XML files

Would it be possible to change the code so that it looks at an URL that ends with /movietexts ?

For example

[http://www.samplewebsite.net/movietexts](http://www.samplewebsite.net/movietexts)  
[http://www.samplewebsite/uk/movietexts](http://www.samplewebsite/uk/movietexts)  
[http://www.samplewebsite/nl/movietexts](http://www.samplewebsite/nl/movietexts)  
[http://www.samplewebsite/XX/movietexts](http://www.samplewebsite/XX/movietexts)

Would this be possible or would a different approach be better?

Thank you in advance!

John
