Xpath进阶
1.模糊指定
- 包含某字段使用contains
所有id包含字符abc的标签a
//a[contains(@id,'abc')]
- 以什么字段开头
所有属性href以‘http://v’开头的a标签
//a[starts-with(@href,'http://v')]
- 以什么字段结尾
所有以’fg’结尾div标签
//div[preceding-sibling::*['fg']]
2.运算符
- 与 and
//div[preceding-sibling::*['fg'] and starts-with(@href,'http://v')]
- 或 or
//div[preceding-sibling::*['fg'] or starts-with(@href,'http://v')]
- 非 not()
//div[not(starts-with(@class,"abc"))]