Throw InvalidXMLException on failed parsing, add tests