Which one would you choose? My important attributes are (not in order):
- Support and future enhancements.
- Community and general knowledge base (on the Internet).
- Comprehensive (I.E., proven to parse a wide range of *.*ml pages).
- Performance.
- Memory footprint (runtime, not the code-base).
Pick Nokogiri, for all points and especially point one: Hpricot is no longer maintained.
Meta answer: See ruby-toolbox to get an idea of the popularity of different tools in a given area.
Only pick Hpricot if you don't have, or can't install, LibXML on the computer you're using. If this is not the case then choose Nokogiri, it's better in the five mentioned attributes than Hpricot.
The case where I've found Hpricot to be useful is in dealing with broken HTML that you need to remain broken after processing. Hpricot is good about modifying only the portion of a document you have updated. Unless this is needed, Nokogiri is the way to go.
来源:https://stackoverflow.com/questions/2888587/nokogiri-vs-hpricot