session CHANGE libyang changes
diff --git a/src/io.c b/src/io.c
index 6e853ab..7d6cc22 100644
--- a/src/io.c
+++ b/src/io.c
@@ -976,7 +976,8 @@
             nc_write_clb((void *)&arg, "<ok/>", 5, 0);
             break;
         case NC_RPL_DATA:
-            lyd_print_clb(nc_write_xmlclb, (void *)&arg, ((struct nc_reply_data *)reply)->data, LYD_XML, LYP_WITHSIBLINGS);
+            assert(((struct nc_reply_data *)reply)->data->schema->nodetype == LYS_RPC);
+            lyd_print_clb(nc_write_xmlclb, (void *)&arg, ((struct nc_reply_data *)reply)->data->child, LYD_XML, LYP_WITHSIBLINGS);
             break;
         case NC_RPL_ERROR:
             error_rpl = (struct nc_server_reply_error *)reply;
diff --git a/src/session_client.c b/src/session_client.c
index 68c8196..f3cb53e 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -198,6 +198,7 @@
     struct nc_rpc *rpc;
     struct nc_reply *reply;
     struct nc_reply_data *data_rpl;
+    struct lyd_node_anyxml *get_schema_data;
     NC_MSG_TYPE msg;
     char *model_data = NULL;
     uint64_t msgid;
@@ -233,10 +234,17 @@
     }
 
     data_rpl = (struct nc_reply_data *)reply;
-    if (((struct lyd_node_anyxml *)data_rpl->data)->xml_struct) {
-        lyxml_print_mem(&model_data, ((struct lyd_node_anyxml *)data_rpl->data)->value.xml, LYXML_PRINT_SIBLINGS);
+    if ((data_rpl->data->schema->nodetype != LYS_RPC) || strcmp(data_rpl->data->schema->name, "get-schema")
+            || !data_rpl->data->child || (data_rpl->data->child->schema->nodetype != LYS_ANYXML)) {
+        ERR("Session %u: unexpected data in reply to a <get-schema> RPC.", session->id);
+        nc_reply_free(reply);
+        return NULL;
+    }
+    get_schema_data = (struct lyd_node_anyxml *)data_rpl->data->child;
+    if (get_schema_data->xml_struct) {
+        lyxml_print_mem(&model_data, get_schema_data->value.xml, LYXML_PRINT_SIBLINGS);
     } else {
-        model_data = strdup(((struct lyd_node_anyxml *)data_rpl->data)->value.str);
+        model_data = strdup(get_schema_data->value.str);
     }
     nc_reply_free(reply);
     *free_model_data = free;
diff --git a/src/session_server.c b/src/session_server.c
index 8205332..90e076e 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -334,12 +334,13 @@
         return NULL;
     }
 
-    data = lyd_output_new_anyxml_str(sdata, model_data);
+    data = lyd_new_path(NULL, server_opts.ctx, "/ietf-netconf-monitoring:get-schema/data", model_data, LYD_PATH_OPT_OUTPUT);
     if (!data) {
         ERRINT;
         free(model_data);
         return NULL;
     }
+    free(model_data);
 
     return nc_server_reply_data(data, NC_PARAMTYPE_FREE);
 }
diff --git a/tests/test_fd_comm.c b/tests/test_fd_comm.c
index 493971c..67602b7 100644
--- a/tests/test_fd_comm.c
+++ b/tests/test_fd_comm.c
@@ -52,15 +52,11 @@
 my_getconfig_rpc_clb(struct lyd_node *rpc, struct nc_session *session)
 {
     struct lyd_node *data;
-    const struct lys_module *module;
 
     assert_string_equal(rpc->schema->name, "get-config");
     assert_ptr_equal(session, server_session);
 
-    module = ly_ctx_get_module(session->ctx, "ietf-netconf-acm", NULL);
-    assert_non_null(module);
-
-    data = lyd_new(NULL, module, "nacm");
+    data = lyd_new_path(NULL, session->ctx, "/ietf-netconf:get-config/data", NULL, LYD_PATH_OPT_OUTPUT);
     assert_non_null(data);
 
     return nc_server_reply_data(data, NC_PARAMTYPE_FREE);