nokogiri-ext

CI Gem Version

Description

nokogiri-ext is a collection of useful extensions to the nokogiri gem.

Features

Requirements

Install

$ gem install nokogiri-ext

gemspec

gem.add_dependency 'nokogiri-ext', '~> 1.0'

Gemfile

gem 'nokogiri-ext', '~> 1.0'

Examples

equality

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 == doc2

traverse_count

Count the total number of elements under a XML/HTML element:

require 'nokogiri/ext/traverse_count'

doc.at('//node').traverse_count
# => 7

Count the total number of elements within a XML/HTML document:

doc.traverse_count
# => 42

traverse_text

Traverses all text nodes in a XML/HTML document or node:

require 'nokogiri/ext/traverse_text'

doc.traverse_text do |text|
  puts text
end

License

See LICENSE for details.