DomDocument::loadXml not throwing exceptions in PHP

For some reason, Zend have decided not to make PHP throw an exception when you try and load invalid XML into a DomDocument object. This includes XML with invalid characters e.g. &. This means wrapping a try/catch around anything does absolutely no good whatsoever, which is annoying.

Is there a good way of trapping runtime errors using loadXml with the DomDocument library?

Leave a Reply

Your email address will not be published. Required fields are marked *