parser xml BUGFIX multi-error for attribute
diff --git a/src/parser_xml.c b/src/parser_xml.c
index a0cf1f5..435203e 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -116,8 +116,10 @@
             if (lydctx->parse_opts & LYD_PARSE_STRICT) {
                 LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Missing mandatory prefix for XML metadata \"%.*s\".",
                         (int)xmlctx->name_len, xmlctx->name);
-                ret = LY_EVALID;
-                goto cleanup;
+                /* If LYD_VALIDATE_MULTI_ERROR is set, then continue parsing, because otherwise the parser context
+                 * will remain in a bad state, which will cause termination on some assert or undefined behavior.
+                 */
+                LY_DPARSER_ERR_GOTO(LY_EVALID, ret = LY_EVALID, lydctx, cleanup);
             }
 
             /* skip attr */
@@ -1059,14 +1061,13 @@
     /* create metadata/attributes */
     if (xmlctx->status == LYXML_ATTRIBUTE) {
         if (snode) {
-            rc = lydxml_metadata(lydctx, snode, &meta);
-            LY_CHECK_GOTO(rc, cleanup);
+            r = lydxml_metadata(lydctx, snode, &meta);
         } else {
             assert(lydctx->parse_opts & LYD_PARSE_OPAQ);
-            rc = lydxml_attrs(xmlctx, &attr);
-            LY_CHECK_GOTO(rc, cleanup);
+            r = lydxml_attrs(xmlctx, &attr);
         }
     }
+    LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
 
     assert(xmlctx->status == LYXML_ELEM_CONTENT);
     if (!snode) {