On this page
Overview
Nokogiri reads and writes HTML4, HTML5, and XML from Ruby and queries elements with CSS selectors or XPath. Its APIs cover DOM and SAX parsing, XSD validation, and XSLT transformation.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Best fit
Embed extraction, transformation, and validation in Ruby
It fits jobs that extract selected elements from pages, ingest XML APIs or feeds, and validate document formats. Parsing local HTML and XML strings demonstrates the core APIs without network access.
Sources: [5]
Before adoption
Test the actual Ruby and native-parser combination
Version 1.19.4 requires Ruby 3.2 or later or JRuby 10 or later, and the underlying parsers differ between CRuby and JRuby. The HTML5 API is unavailable on JRuby. The project deliberately surfaces meaningful parser differences, so validation should match the production implementation and platform.
Sources: [1]
Official sources
- [1]sparklemotion/nokogiri README (1.19.4)(2026-10-04)
- [2]sparklemotion/nokogiri GitHub repository metadata(2026-10-04)
- [3]sparklemotion/nokogiri license (1.19.4)(2026-10-04)
- [4]Nokogiri 1.19.4 release(2026-10-04)
- [5]Nokogiri official documentation(2026-10-04)
Supplemental curator note
Its uses extend beyond screen scraping to XML integrations, feed processing, and document validation. Treat input as untrusted and test with the same Ruby implementation, native gem, and underlying parser combination used in production.
Try it in 3 steps
- 1
Check CRuby and Bundler, then add the fixed version
Require CRuby 3.2 or later for the HTML5 API, verify Bundler, and install v1.19.4 in an isolated bundle.
ruby -e 'abort "CRuby 3.2+ required for HTML5" unless RUBY_ENGINE=="ruby" && Gem::Version.new(RUBY_VERSION)>=Gem::Version.new("3.2")' && bundle --version && mkdir nokogiri-local && cd nokogiri-local && bundle init && bundle add nokogiri --version 1.19.4 - 2
Create a local HTML and XML check
Parse an in-memory HTML5 document with a CSS selector and XML with XPath.
printf '%s\n' 'require "nokogiri"' 'html = Nokogiri::HTML5("<main><h1>OSS探訪</h1></main>")' 'xml = Nokogiri::XML("<items><item id=\"1\">local</item></items>") { |config| config.strict }' 'puts [html.at_css("h1").text, xml.at_xpath("//item[@id=\"1\"]").text].join(" | ")' > parse.rb - 3
Verify the parsed values
Confirm that OSS探訪 | local is printed from the two documents.
bundle exec ruby parse.rb
Growth
Growth trends · Last 30 days
6,284 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 7
- Open PRs
- 44
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- ruby
- nokogiri
- xml
- sax
- ruby-gem
- xslt
- xerces
- libxml2
- libxslt
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Scrapy64,578 Stars
1 shared tag(s) · 1 shared category(s)
Crawl websites and send extracted structured data through reusable pipelines
Python - Prettier52,314 Stars
1 shared tag(s) · 1 shared category(s)
an opinionated formatter that parses code and reprints a consistent style
JavaScript - Jekyll51,707 Stars
1 shared tag(s) · 1 shared category(s)
generate blog-aware static sites from Markdown and Liquid
Ruby - Homebrew49,884 Stars
1 shared tag(s) · 1 shared category(s)
manage macOS and Linux software through the
Rubybrewpackage workflow - Apache Spark44,116 Stars
1 shared tag(s) · 1 shared category(s)
Process SQL, DataFrames, streams, and machine learning on one distributed engine
Scala - fastlane42,201 Stars
1 shared tag(s) · 1 shared category(s)
automate repeatable iOS and Android build, signing, screenshot, and store-release workflows as lanes
Ruby
Report incorrect information
Tell us if any listing information is incorrect or outdated.