Tutorial by Examples

Detailed instructions on getting Nokogiri set up or installed.
There isn't much to add to Nokogiri's "Parsing an HTML/XML Document" tutorial, which is an easy introduction to the subject, so start there, then return to this page to help fill in some gaps. Nokogiri's basic parsing attempts to clean up a malformed document, sometimes adding missing clo...
Nokogiri is somewhat like a browser, in that it will attempt to provide something useful even if the incoming HTML or XML is malformed. Unfortunately it usually does it silently, but we can ask for a list of the errors using errors: require 'nokogiri' doc = Nokogiri::XML('<node><foo/&gt...
How to correctly extract text from nodes is one of the most popular questions we see, and almost invariably is made more difficult by misusing Nokogiri's "searching" methods. Nokogiri supports using CSS and XPath selectors. These are equivalent: doc.at('p').text # => "foo"...

Page 1 of 1