parse XML files; some bug fixing