Added error handling for malformed XML 

If you have malformed XML/HTML inside a code block DOMDocument->loadXML will break the entire parser.