Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What’s the purpose of Nokogiri in Rails?

Nokogiri is the bane of my existence. It makes my rails new command fail for a different reason every time I create a new Rails app.

There’s a ton of Nokogiri troubleshooting on StackOverflow, but, I can’t find, neither here nor elsewhere, the reason why Nokogiri is included with Rails. The Nokogiri documentation states that it’s used for parsing, searching, and modifying HTML/XML documents, but, what purpose, if any, does it serve if I’m not screen scraping?

like image 369
lgants Avatar asked Jan 22 '17 20:01

lgants


1 Answers

Nokogiri is an XML/HTML/CSS parser. So if you want to programatically read or edit an XML document Nokogiri is the way to go.

Nokogiri is a dependency of rails-dom-testing which is required by Rails.

As far as I see it rails-dom-testing is used to verify certain parts of a rendered HTML/CSS page.

like image 100
leifg Avatar answered Oct 15 '22 21:10

leifg