XPath several different key concepts ......
Absolute vs relative XPath ( /
vs .
)
-
/
The introduction of absolute location path, starting from the root of the document. -
.
From the introduction of the context node start position relative path.
Naming any element elements VS ( ename
VS *
)
-
/ename
Select aename
root element -
./ename
Selectename
all child elements of the current node. -
/*
Select the root element, regardless of the name. -
./*
Or*
select all children of the context node, regardless of the name.
Descendant or self axis //*
( )
-
//ename
Selectename
all elements in the document. -
.//ename
Selectename
context node or in all elements. -
//*
Select all elements in the document, regardless of the name. -
.//*
Select all the elements of the context node or below, regardless of the name.
Taking into account these concepts, here are answers to your specific questions ......
-
.//*[@id='Passwd']
Indicating the selection or the current context node havingid
all the elements of the property is equal'Passwd'
. -
//child::input[@type='password']
It can be simplified,//input[@type='password']
and means selectinginput
a documenttype
all elements of property values equal'password'
.
/ AAA / BBB / following-sibling :: * after taking all the sibling nodes / AAA / BBB node
reference:
http://www.imooc.com/wenda/detail/579577
https://www.cnblogs.com/zhaozhan/archive/2009/09/10/1564332.html