title: Nodejs get result from callback
body: <p>i'm tryna get my array of results out of the callback method, the array is containing all of those things i want in but i can use it outside of the functions always keep undefined result. I was looking on many website for helping me to improve it but no results.</p>
  
  <pre><code>var DOMParser = require('xmldom').DOMParser;
  var fs = require('fs');
  var Initializer = require('./Initializer');
  var StaticRoomList = Initializer.getStaticRoomList(fs, DOMParser);
  console.log(StaticRoomList);
  
  openRoomListXML = function(fs, DOMParser, callback){
  try{
      fs.readFile('./XML/RoomList.xml', function(e, data){
          if(e){
              callback(e);
          }
          else{
              var BuffertoXMLString = String(data);
              var XMLOutput = new DOMParser().parseFromString(BuffertoXMLString, "text/xml");
              var XMLDocument = XMLOutput.documentElement;
              callback(null, XMLDocument);
          }
  
      });
  
  }
  catch(fsException){
      console.log(fsException);
  }
  };
  
  getStaticRoomList = function(fs, DOMParser){
  openRoomListXML(fs, DOMParser, function readList(e, XMLDocument){
      if(e){
          console.log(e);
      }
      else{
          var nodeList = XMLDocument.getElementsByTagName("room");
          var arrayRoomList = [];
          for(i = 0; i &lt; nodeList.length; i++){
              arrayRoomList.push(nodeList[i].childNodes[0].nodeValue);
          }
          return arrayRoomList;
      }
  });
  };
  
  
   exports.getStaticRoomList = getStaticRoomList;
  </code></pre>