module Nokogiri

Nokogiri parses and searches XML/HTML very quickly, and also has correctly implemented CSS3 selector support as well as XPath 1.0 support.

Parsing a document returns either a Nokogiri::XML::Document, or a Nokogiri::HTML4::Document depending on the kind of document you parse.

Here is an example:

require 'nokogiri'
require 'open-uri'

# Get a Nokogiri::HTML4::Document for the page we’re interested in...

doc = Nokogiri::HTML4(URI.open('http://www.google.com/search?q=tenderlove'))

# Do funky things with it using Nokogiri::XML::Node methods...

####
# Search for nodes by css
doc.css('h3.r a.l').each do |link|
  puts link.content
end

See also: