1. Contains()
//a[contains(@href,‘from_pc_logon’)]
2. start-with()
//a[starts-with(@href,‘https’)] # 将定位以https开头的元素
3. Text()
//a[text()=‘地图’]
4. last()方法
//div/div[2]/div[2]/a[last()]
5. 逻辑表达式-and
//a[text()=‘地图’ and contains(@href,‘map’)]
6.逻辑表达式-or
//a[text()=‘地图’ or contains(@href,‘map’)]
7. Not查找
//a[not(text()=‘地图’)]
8. 大于号,小于号
//a[text()>0 or text()>‘0’] # 结果只有1条
9. 轴方式定位
轴表达式说明
parent::* :表示当前节点的父节点元素
ancestor::* :表示当前节点的祖先节点元素
child::* :表示当前节点的子元素 /A/descendant::* 表示A的所有后代元素
self::* :表示当前节点的自身元素
ancestor-or-self::* :表示当前节点的及它的祖先节点元素
descendant-or-self::* :表示当前节点的及它们的后代元素
following-sibling::* :表示当前节点的后序所有兄弟节点元素
preceding-sibling::* :表示当前节点的前面所有兄弟节点元素
following::* :表示当前节点的后序所有元素
preceding::* :表示当前节点的所有元素