QuestionQ63

NETCONF/XML API

Referring to the exhibit, which XPath statement should be used to retrieve only user2's user ID value?

Question Image

  • A ./system/login/user2/uid
  • B ./system/login/user<name='user2'>/uid
  • C ./system/login/user[name='user2']/uid
  • D ./system/login/user/uid
Explanation

In XPath, predicates are expressed using square brackets containing a condition, in the form element[child='value']. Since the configuration hierarchy is system/login/user, with each user node containing a <name> child (e.g., 'user1', 'user2') and a <uid> child, the correct way to select the uid belonging specifically to the user whose name is 'user2' is user[name='user2']/uid. This filters the set of <user> nodes to the one whose <name> equals 'user2', then retrieves its <uid> child value.

Community Discussion

No comments yet. Be the first to start the discussion!