is it possible to read 2 config blocks using maapi API?
I’m able to read one config block & entire config block using maapi_save_config() API as follows
Specific config block
maapi_save_config (sock, thandle, MAAPI_CONFIG_XML_PRETTY, "/ManagedElemen");
Entire config block
maapi_save_config (sock, thandle, MAAPI_CONFIG_XML_PRETTY, NULL);
How to read 2 config blocks, say “/ManagedElement” & “/hardware”
Hello,
I haven’t tested this myself, but…
confd_lib_maapi man page for maapi_save_config()
shows that this flag is available:
MAAPI_CONFIG_XPATH
The fmtpath and remaining arguments give an XPath filter instead of a keypath.
...
so something like this could maybe work:
int flags = MAAPI_CONFIG_XML_PRETTY | MAAPI_CONFIG_XPATH;
char *xpath = "child::*[self::ManagedElement or self::hardware]";
maapi_save_config(sock, thandle, flags, xpath);
You may need to play with format of the xpath a bit, i’m not sure if it needs e.g. leading / and cannot test myself now…
edit: or maybe xpath like: “/*[@name=ManagedElement or @name=hardware]
”, there seem to be more options depending on axes/attributes usage…?
Thanks. Following one is working for me
char xpath = "child::[self::ManagedElement or self::hardware]";
I tried with “ /*[@name=ManagedElement or @name=hardware] ”. But not worked.
1 Like