parsers FEATURE accept only subtree for notif and RPC
diff --git a/src/parser_json.c b/src/parser_json.c
index a7b7e54..578070d 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1551,13 +1551,9 @@
         goto cleanup;
     }
 
-    /* read subtree(s) */
-    while (lydctx->jsonctx->in->current[0] && status != LYJSON_OBJECT_CLOSED) {
-        ret = lydjson_subtree_r(lydctx, NULL, &tree);
-        LY_CHECK_GOTO(ret, cleanup);
-
-        status = lyjson_ctx_status(lydctx->jsonctx, 0);
-    }
+    /* read subtree */
+    ret = lydjson_subtree_r(lydctx, NULL, &tree);
+    LY_CHECK_GOTO(ret, cleanup);
 
     /* finish linking metadata */
     ret = lydjson_metadata_finish(lydctx, &tree);
@@ -1568,6 +1564,11 @@
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the \"notification\" node.");
         ret = LY_EVALID;
         goto cleanup;
+    } else if (lydctx->jsonctx->in->current[0] && lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED) {
+        LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
+               tree->schema->name);
+        ret = LY_EVALID;
+        goto cleanup;
     }
 
     if (ntf_e) {
@@ -1719,12 +1720,8 @@
     assert(status == LYJSON_OBJECT);
 
     /* read subtree(s) */
-    while (lydctx->jsonctx->in->current[0] && status != LYJSON_OBJECT_CLOSED) {
-        ret = lydjson_subtree_r(lydctx, act_e ? (struct lyd_node_inner*)act_e : (struct lyd_node_inner*)rpc_e, &tree);
-        LY_CHECK_GOTO(ret, cleanup);
-
-        status = lyjson_ctx_status(lydctx->jsonctx, 0);
-    }
+    ret = lydjson_subtree_r(lydctx, act_e ? (struct lyd_node_inner*)act_e : (struct lyd_node_inner*)rpc_e, &tree);
+    LY_CHECK_GOTO(ret, cleanup);
 
     /* finish linking metadata */
     ret = lydjson_metadata_finish(lydctx, &tree);
@@ -1736,6 +1733,11 @@
                act_e ? "action" : (rpc_e ? "rpc" : "rpc/action"));
         ret = LY_EVALID;
         goto cleanup;
+    } else if (lydctx->jsonctx->in->current[0] && lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED) {
+        LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
+               tree->schema->name);
+        ret = LY_EVALID;
+        goto cleanup;
     }
 
     if (act_e) {
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 58508f6..1b8584a 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -755,15 +755,18 @@
     }
 
     /* parse the rest of data normally */
-    while (lydctx.xmlctx->status == LYXML_ELEMENT) {
-        LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
-    }
+    LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
 
-    /* make sure we have parsed some operation */
+    /* make sure we have parsed some operation and it is the only subtree */
     if (!lydctx.op_node) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the \"rpc\"/\"action\" node.");
         ret = LY_EVALID;
         goto cleanup;
+    } else if (lydctx.xmlctx->status == LYXML_ELEMENT) {
+        LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
+               tree->schema->name);
+        ret = LY_EVALID;
+        goto cleanup;
     }
 
     /* finish XML parsing and check operation type */
@@ -939,15 +942,18 @@
     LY_CHECK_GOTO(ret = lydxml_notif_envelope(lydctx.xmlctx, &ntf_e), cleanup);
 
     /* parse the rest of data normally */
-    while (lydctx.xmlctx->status == LYXML_ELEMENT) {
-        LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
-    }
+    LY_CHECK_GOTO(ret = lydxml_subtree_r(&lydctx, NULL, &tree), cleanup);
 
     /* make sure we have parsed some notification */
     if (!lydctx.op_node) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the \"notification\" node.");
         ret = LY_EVALID;
         goto cleanup;
+    } else if (lydctx.xmlctx->status == LYXML_ELEMENT) {
+        LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
+               tree->schema->name);
+        ret = LY_EVALID;
+        goto cleanup;
     }
 
     /* finish XML parsing */