The test module is like this:
module test {
namespace "urn:test:yang:test";
prefix tst;
revision 2019-01-01;
rpc test {
output {
container a {
leaf x {
type string;
}
}
container b {
leaf y {
type string;
}
}
}
}
}
Then build two subtrees by lyd_new_path:
lyd_node* first = lyd_new_path(NULL, ctx, "/test:test/b/y", NULL, 0, LYD_PATH_OPT_OUTPUT);
lyd_node* second = lyd_new_path(NULL, ctx, "/test:test/a/x", NULL, 0, LYD_PATH_OPT_OUTPUT);
When using lyd_merge function to merge the second one into the first one:
lyd_merge(first, second, 0);
The return was success but the first->child was NULL.