public static function throwFromLibXml()
    {
        $errors = libxml_get_errors();
        if (count($errors)) {
            libxml_clear_errors();
        }
        $lastException = null;
        /** @var \LibXMLError $error */
        foreach ($errors as $error) {
            $current = new self($error->message, 0, $lastException);
            $lastException = $current;
        }
        if (null !== $lastException) {
            throw $lastException;
        }
    }