CSS Selectors?

mattseh

import this
Apr 6, 2009
5,504
72
0
A ~= A
Why?

Versus xpath, I can't see an advantage? I notice lxml converts css selectors to xpath behind the scenes, so it seems xpath can do everything css selectors can do?
 


Xpath is a functional language (there is no built-in concept of state or volatile storage). CSS selectors are expression matching constructs that are convenient for entities that can be expressed with a DOM L1 1.0 interface. Xpath can do more but it's generally more than needed for cases where CSS selectors might be sufficient.

In other words, it's about the same answers as "why might a hammer be better than a nail gun for hanging a variety of paintings."