When should one use one or the other, would you say?
When should one use one or the other, would you say?
I've heard that `lxml` can choke on certain badly-formed markup, but it's very fast. Personally has never failed on me.
Also, a question: how often do you really encounter badly-formed markup in the wild? How hard is it really to get HTML right? It seems pretty simple, just close tags and don't embed too much crazy stuff in CDATA. Yet I often read about how HTML parsers must be "permissive" while XML parsers don't need to be. I've never had a problem parsing bad markup; usually my issues have to do with text encoding (either being mangled directly or being correctly-encoded vestiges of a prior mangling) and the other usual problems associated with text data.
[0]: https://benbernardblog.com/tracking-down-a-freaky-python-mem...
Recommendation by the author (of Calibre fame) on a similar discussion: https://news.ycombinator.com/item?id=15539853
Dedicated discussion: https://news.ycombinator.com/item?id=14588333
If you're familiar with writing XPath queries, lxml is great.