HTML、XML、SAX解析ライブラリ「nokogiri」をインストールした

nokogiriとは、HTML、XML、SAXをパースするライブラリです。

Nokogiri is an HTML, XML, SAX, and Reader parser. Among Nokogiri’s many features is the ability to search documents via XPath or CSS3 selectors.
XML is like violence - if it doesn’t solve your problems, you are not using enough of it.


nokogiriのインストールですが、まずlibxml2-devとlibxslt1-devをインストールします。

$ sudo aptitude install libxml2-dev
$ sudo aptitude install libxslt1-dev

次にnokogiriをインストールするのですが、nokogiriを動かすのに必要なライブラリも一緒にインストールします。*1 *2

$ sudo gem install racc
$ sudo gem install rexical
$ sudo gem install hoe
$ sudo gem install nokogiri


http://nokogiri.rubyforge.org/nokogiri/
http://github.com/tenderlove/nokogiri/tree/master

*1:racc、rexical、hoeがなくてもnokogiriのインストールは可能ですが、require時にエラーがでます。

*2:hoeのインストールには、RubyGems 1.3.1以上が必要です。