/** * @param string $xml * @throws ParserException */ public static function validXml($xml) { $useErrors = libxml_use_internal_errors(true); $isCorrect = simplexml_load_string($xml); if ($isCorrect === false) { libxml_use_internal_errors($useErrors); throw ParserException::notXml($xml); } libxml_use_internal_errors($useErrors); }