# XML loading too many times

**URL:** <https://forum.kirupa.com/t/xml-loading-too-many-times/241030>\
**Category:** Uncategorized\
**Created:** [October 9, 2007, 2:42pm UTC](https://forum.kirupa.com/t/xml-loading-too-many-times/241030 "2007-10-09T14:42:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stotion](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@stotion](https://forum.kirupa.com/u/stotion)\
**Post date:** [October 9, 2007, 2:42pm UTC](https://forum.kirupa.com/t/xml-loading-too-many-times/241030/1 "2007-10-09T14:42:47Z")

</div>

I have 50 US State buttons with similar code pasted onto each button. It loads the XML each time. How do I need to change my code to make it so I only need to load the XML once for all 50 states?

Thanks in advance!

```auto
on (release) {
	function loadXML(loaded) {
if (loaded) {
_root.sname = this.firstChild.childNodes[4].childNodes[0].firstChild/*.nodeValue*/;
_root.rep = this.firstChild.childNodes[4].childNodes[1].firstChild/*.nodeValue*/;
_root.email = this.firstChild.childNodes[4].childNodes[2].firstChild/*.nodeValue*/;
_root.phone = this.firstChild.childNodes[4].childNodes[3].firstChild/*.nodeValue*/;
_root.mc_email_link = "mailto:"+this.firstChild.childNodes[4].childNodes[2].firstChild/*.nodeValue*/;
sname_txt.text = _root.sname;
rep_txt.text = _root.rep;
email_txt.text = _root.email;
phone_txt.text = _root.phone;
mc_email.onRelease = function () {
	getURL(mc_email_link);
}
//set color
_root.greenMcs.gotoAndStop("ncac");

trace(mc_email_link);

} else {
  trace("file not loaded!");
}
}
this.mc_rep_tag.gotoAndPlay(2);

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("reps2.xml");
}

```
