In this article we are going to illustrate how to send the XGET request to the server with different XPath operators and functions.

The server fully supports all the XPath expressions, functions and operators with the XGET command.


For example, in order to request an interface with name "test2" and or an interface with name "test3" the XPath may look as follows:


> xget "/interfaces/interface[name='test2'] | /interfaces/interface[name='test3']"


Please, note that the '|' operator "Computes two node-sets", whereas the "or" would try to follow regular "or" operator logic.

That's, in case of the following request:


> xget "/interfaces/interface[name='test2'] or /interfaces/interface[name='test3']"


The server would return only one or another "interface" list node. But in case of "|" the server will combine two sides of the expression and return both nodes if they both exist.


NOTE:

The syntax "list-node[key-node="value"]" is only for list nodes and cannot be used for containers.


In order to get all list entries that have some specific child node, and or some specific child's child node, the following XPath expressions can be used:


// To get all the "interface" list nodes that has children container with some node that is set to a specific value
> xget "/interfaces/interface/some-container[contains(text(),'specific-value')]"

// To get all the "interface" list nodes that has children container with a specific node that is set to a specific value
> xget "/interfaces/interface/some-container/specific-leaf[contains(.,'specific-value')]"