Referring to the exhibit below, which two XPath expressions will select all user nodes?
In XPath, //user is an abbreviation for /descendant-or-self::node()/user, meaning it searches the entire document tree for any element named user, regardless of depth, so it always returns all three <user> elements shown under system/login. The expression ./system/login/user is a relative path that, starting from the context node (the document/system root), explicitly walks down through system, then login, then user, matching the exact nesting shown in the exhibit and returning all three <user> nodes as well. By contrast, ./user only looks for user as a direct child of the current context node, which does not match because user is nested inside login (three levels down), and @user attempts to select an attribute named user rather than an element, which does not exist in the configuration hierarchy shown.
//user
/descendant-or-self::node()/user
user
<user>
system/login
./system/login/user
system
login
./user
@user
Community Discussion