The SAX Parser behaves a little differently and you can actually just set it to recover from any errors. You can also use the error handler method to deal with specific errors.
class MyDoc < Nokogiri::XML::SAX::Document
def error(error)
puts "An error occurred: #{error}"
end
def start_element(name, attributes = [])
puts "found a #{name}"
end
end
parser = Nokogiri::HTML::SAX::Parser.new(MyDoc.new)
parser.parse(open(url)) do |ctx|
ctx.recovery = true
end