Fixes #3781: improve error message in XML parsing