The XML parser used to rely in C++ exceptions while parsing, which is an artifact from the initial implementation. This patch reworks the code such that exceptions are avoided in the common cases. Fixes #3605