What's the best way to parse HTML/XML efficiently with lxml Python? or How do you handle large XML fi

20 Replies, 1077 Views

`etree` all the way if you’re working with clean XML. The `xpath()` method is blazing fast for queries.

For HTML, yeah, the `html` module is better, but if speed’s your goal, avoid too many XPath calls—they add up.

Also, pre-compile your XPaths with `etree.XPath()` if you reuse them. Saves a ton of time!

Messages In This Thread



Users browsing this thread: 1 Guest(s)