freeing XML doc pointer after usage, otherwise we have a memory leak