nokogiri-ext is a collection of useful extensions to the nokogiri gem.
- Adds an
==method to {Nokogiri::XML::Element}, {Nokogiri::XML::Attr}, {Nokogiri::XML::Text}, {Nokogiri::XML::Node}. - Adds a
traverse_countmethod to {Nokogiri::XML::Document} and {Nokogiri::XML::Node}. - Adds the {Nokogiri::XML::Node#traverse_text} method.
$ gem install nokogiri-extgem.add_dependency 'nokogiri-ext', '~> 1.0'gem 'nokogiri-ext', '~> 1.0'Compare the contents of two XML/HTML elements:
require 'nokogiri/ext/equality'
doc1.at('//node') == doc2.at('//node')Comparing the contents of two XML/HTML documents:
doc1 == doc2Count the total number of elements under a XML/HTML element:
require 'nokogiri/ext/traverse_count'
doc.at('//node').traverse_count
# => 7Count the total number of elements within a XML/HTML document:
doc.traverse_count
# => 42Traverses all text nodes in a XML/HTML document or node:
require 'nokogiri/ext/traverse_text'
doc.traverse_text do |text|
puts text
endSee {file:LICENSE.txt} for details.