Added internal error handling before simplexml call