# Undefined being returned instead of xml node value

**URL:** <https://forum.kirupa.com/t/undefined-being-returned-instead-of-xml-node-value/44301>\
**Category:** Uncategorized\
**Created:** [March 2, 2004, 6:11pm UTC](https://forum.kirupa.com/t/undefined-being-returned-instead-of-xml-node-value/44301 "2004-03-02T18:11:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwu](https://avatars.discourse-cdn.com/v4/letter/g/43a26b/32.png) [@gwu](https://forum.kirupa.com/u/gwu)\
**Post date:** [March 2, 2004, 6:11pm UTC](https://forum.kirupa.com/t/undefined-being-returned-instead-of-xml-node-value/44301/1 "2004-03-02T18:11:52Z")

</div>

I am trying to call a functoin which will use the xml object to retrieve data and return the data to the function call. When I trace “test\_var” inside the “book\_xml.onLoad” functoin, it works. but I can pass the xml data out of the get\_data function. Can anyone help???

* * *

stop();

//define function  
function get\_data(id) {  
book\_xml = new XML();  
book\_xml.ignoreWhite = true;  
book\_xml.onLoad = function(sucess) {  
test\_var = book\_xml.firstChild.childNodes[0].childNodes[0].firstChild;  
};  
book\_xml.load(“school\_xml.asp?id=” + id);  
return test\_var;  
}

//call function and retriev value  
ret\_var = get\_data(“105”);

//trace value  
trace(ret\_var);

* * *
