# XML Import to Variables

**URL:** <https://forum.kirupa.com/t/xml-import-to-variables/197744>\
**Category:** flash\
**Created:** [August 18, 2006, 5:57pm UTC](https://forum.kirupa.com/t/xml-import-to-variables/197744 "2006-08-18T17:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickM](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@PatrickM](https://forum.kirupa.com/u/PatrickM)\
**Post date:** [August 18, 2006, 5:57pm UTC](https://forum.kirupa.com/t/xml-import-to-variables/197744/1 "2006-08-18T17:57:51Z")

</div>

I have followed everything i could but my lack of experence with actioscript has be stuck with where variables can be accessed when using functions, well here is what i have and it’s pretty easy to see what i am trying to do

```auto
function loadXML(loaded) {
    if (loaded) {
        _root.username = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        _root.passcode = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        name_txt.text = _root.username;
        pass_txt.text = _root.passcode;
    } else {
      trace("file not loaded!");
    }
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("c:/get.xml");

// this is where we need to access the variable
trace (_root.username); 
trace (name_txt.text);
trace (name_txt);

test = "Need Variable Here: " + name_txt.text;

```

I just need to be able to have a variable with the username available outside the function… i don’t even know if this is a simple or complex problem
