recursive lookup and xml repair scripts