0.0
Low commit activity in last 3 years
A collection of useful extensions to the nokogiri gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0

Runtime

~> 1.0
 Project Readme

nokogiri-ext

CI Gem Version

Description

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

Features

  • Adds an == method to {Nokogiri::XML::Element}, {Nokogiri::XML::Attr}, {Nokogiri::XML::Text}, {Nokogiri::XML::Node}.
  • Adds a traverse_count method to {Nokogiri::XML::Document} and {Nokogiri::XML::Node}.
  • Adds the {Nokogiri::XML::Node#traverse_text} method.

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 {file:LICENSE.txt} for details.