Xpath online testing tool
expression |
effect |
nodename |
Select the All Child node |
/ |
Representative selects from the root node |
// |
It can be understood as matching, that is, selecting this node from all nodes until matching |
. |
Select the current node |
… |
Select the next level above the current node (the next level directory) |
@ |
Select properties (also matching) |
mode |
effect |
/html/body/div |
It means to search from the root node, and between tags/represents a hierarchy |
/html//div |
It indicates that multiple levels act between two tags (it can also be understood as matching to find tag div under html) |
//div |
Start from any node, that is, find all div tags |
./div |
Indicates that the div is searched from the current tag |
demand |
format |
Locate the div tag whose attribute name is href and attribute value is' www.baidu. com ' |
@Attribute Name=Attribute Value |
Href is the attribute name 'www.baidu. com' is the attribute value |
/html/body/div[href=‘www.baidu.com’] |
demand |
format |
Locate the second li label under ul (as shown below) |
//ul/li[2] |
Index value starts at |
one |
method |
effect |
/text() |
Get the label content directly under the label |
//text() |
Get all the text content in the label |
string() |
Get all the text content in the label |
regular expression
- Based on XML, Xpath provides users with the ability to find nodes in the data structure tree. It is affectionately called a mini query language by many developers