xpath常用語句

2021-10-17 11:29:18 字數 905 閱讀 8402

① * 代表匹配所有元素節點

② @*匹配所有屬性節點

③ node()匹配任何型別的節點

31)根目錄/任意位置查詢我們想要提取到「xpath常用語句」這句話,利用/從根目錄進行查詢為(/html/body/div[@class=「head」]/h1/text())

如果使用相對路徑查詢:(//div[@class=「head」]/h1)

2) 相同標籤的具體位置

當然可以選擇利用不同的id來區分,但是有沒有簡單一點的方法呢,肯定是有的,假設想拿到第三個span裡面的內容可以這樣寫://div[@class=「head」]/span[3],其他標籤同理。

3)獲取標籤屬性

我們想根據「2」這個內容獲取到href,(//span[contains(text(),『2』)]/a/@href)

5)last()函式

想獲取某個標籤裡面最後乙個(//div[@class=「head」]/span[last()])

6)position()函式,定位到固定位置

(//div[@class=「head」]/span[position()]<2)這樣獲取到的就是前二個span.

7)start-with()從開始的位置匹配

(//div[@class=『head』]/span[start-with(@class,『aaa』)])

mysql常用語句 MySQL常用語句

create table student id int primary key auto increment comment 學號 name varchar 200 comment 姓名 age int comment 年齡 comment 學生資訊 修改表注釋 alter table studen...

php mysql 常用語句 mysql常用語句

一 修改mysql使用者密碼 mysql h localhost u root p 命令列登入 update user set password password 123456 where user root 二 資料庫操作 show databases 顯示資料庫 create database ...

sql常用語句

use myoa select from delete from department where departmentid 1 insert department departmentid,departmentname values 1,技術部 update department set depa...