Coder Social home page Coder Social logo

nokogiri-ext's Introduction

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.

nokogiri-ext's People

Contributors

postmodern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nokogiri-ext's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.