improve error message when xml parsing fails
Tidied.