There are several distinct, key XPath concepts in play here…
Absolute vs relative XPaths (/
vs .
)
/
introduces an absolute location path, starting at the root of the document..
introduces a relative location path, starting at the context node.
Named element vs any element (ename
vs *
)
/ename
selects anename
root element./ename
selects allename
child elements of the current node.
/*
selects the root element, regardless of name../*
or*
selects all child elements of the context node, regardless of name.
descendant-or-self axis (//*
)
//ename
selects allename
elements in a document..//ename
selects allename
elements at or beneath the context node.
//*
selects all elements in a document, regardless of name..//*
selects all elements, regardless of name, at or beneath the context node.
With these concepts in mind, here are answers to your specific questions…
.//*[@id='Passwd']
means to select all elements at or beneath the
current context node that have anid
attribute value equal to
'Passwd'
.//child::input[@type="password"]
can be simplified to
//input[@type="password"]
and means to select allinput
elements
in the document that have antype
attribute value equal to'password'
.