2021年1月20日星期三

Difference between XPath and css selector


https://gist.github.com/slotix/11f0930b2d46d2946249a10e6216735b#file-css3vsxpath-csv


GoalCSS 3XPath
All Elements*//*
All P Elementsp//p
All Child Elementsp>*//p/*
Element By ID#foo//*[@id=’foo’]
Element By Class.foo//*[contains(@class,’foo’)]
Element With Attribute*[title]//*[@title]
First Child of All Pp>*:first-child//p/*[0]
All P with an A childNot possible//p[a]
Next Elementp + *//p/following-sibling::*[0]
Previous ElementNot possible//p/preceding-sibling::*[0]

没有评论: