var z = new XML(); z.onData = function (data) { // do something with data here } z.load ("file.txt");