Wait until XML file loaded?

Hi, I’m trying to load an external XML file into my program using onLoad callback function. The problem is that the script will continue to run without waiting for the file to load. Is there a way to do that?