I understand that CSS selection is as specific as you can describe the shape of an element, including his: tags, classes, IDs, and the combination of these, the goal is to determine the element's unique coordinates as much as possible to facilitate selection. XPath is based on the path of the element to determine the coordinates.
For example, the description of Shanghai, with CSS may be that it is a municipality (class), in the lower reaches of the Yangtze River (label), is China's largest city (ID), populous, economically developed (other labels)
The XPath is: it is longitude 121°.4′, north latitude 31°.2′ City (absolute path) or south of Jiangsu, Zhejiang Province, east of Suzhou, Yangtze River estuary (relative path)
CSS selection is based on the data style of the page, there are tag selection, class selection, id selection, or their orthogonal set, there is no other auxiliary elements.
XPath is a path expression, and all elements and content can be part of a path. The two positioning methods are basically consistent, but XPath is significantly more powerful, but XPath is more complex to write, and CSS is easier to write.
Have done some experiments, with CSS sometimes choose a bunch of data, with XPath is the only, more useful tools such as Firefox plug-in view XPath, can be more accurate direct selection
In fact, sometimes encounter two elements of the label, class, id exactly the same situation, this time with CSS is more difficult to do, although this situation is very few. However, the XPath absolute path can be resolved
Have you ever thought of the difference between CSS positioning and XPath?