3 ms·
CSS is nice because it's more readable than XPATH for longer queries, and is friendlier to newer programmers who didn't come up when XML was big. XPATH is gene
by showerst 4y ago
CSS is nice because it's more readable than XPATH for longer queries, and is friendlier to newer programmers who didn't come up when XML was big.
XPATH is generally more powerful for really gnarly things and for backtracking. "Show me the 3rd paragraph that's a sibling of the fourth div id="subhed" and contains the text "starting".
- dotancohen 4y ago> XPATH is generally more powerful... That is a convincing argument is you can back it up with an XPATH expression.
- mdaniel 4y agoWell, the rest of their sentence summed it up pretty well; try and implement that example using CSS selectors Hell, even "find id=subhead and _go up one element_" isn't possible in CSS because that's not a problem it was designed to solve
- showerst 4y agoHere’s an example of parsing some particularly annoying old school html. I’m not claiming it’s the _best_ way to do it, just that you can, and I’m not sure this one is doable with selectors. https://github.com/openstates/openstates-scrapers/blob/40246156dcd56ecaeb6130d6b610813992d90093/scrapers/mo/bills.py#L578 https://github.com/openstates/openstates-scrapers/blob/40246...