Does confd_cs_node_cd("/") work?

does confd_cs_node_cd("/") work? In my opinion it should give root node with respect to schema downloaded.

Ok as per user guide it says it wont work.

Note however that the confd_cs_node tree does not have a node
corresponding to “/”. Do we have any other way to get toplevel of a namespace or string name?

See for example the confd_types(3) man page:

The confd_find_cs_root() function returns the root of the tree for a given namespace, and the confd_find_cs_node(), confd_find_cs_node_child(), and confd_cs_node_cd() functions are useful for navigating the tree.

Quick example:

container system {
    list port {
      key name;
      leaf name {
        type string;
struct confd_cs_node *root, *node;
char *path = "/system/port";

root = confd_find_cs_root(my__ns);
node = confd_cs_node_cd(root, "%s/name", path);
confd_val2str(node->info.type, &name, buf, sizeof(buf));
printf(" name = %s ", buf);

Read also the more detailed description of confd_find_cs_root() in the confd_lib_lib(3) man page:

   When schema information is available to the library, this function
   returns the root of the tree representaton of the namespace given by
   ns, i.e. a pointer to the struct confd_cs_node for the (first) toplevel
   node.  [...]

I.e. the schema indeed does not have a root in the sense of “/”, and a namespace can have any number of nodes at the top level. The other toplevel nodes (if any) can be found by walking the ‘next’ list until the pointer is NULL or the ‘ns’ element changes.