Moxml: Modern XML processing for Ruby

Build Status Gem Version

Moxml provides a unified, modern XML processing interface for Ruby applications. It offers a consistent API that abstracts away the underlying XML implementation details while maintaining high performance through efficient node mapping and native XPath querying.

Key features

  • Unified interface - Consistent API across different XML libraries

  • Multiple adapters - Support for Nokogiri, LibXML, Oga, REXML, Ox, and HeadedOx

  • Full XPath support - Native XPath querying with namespace handling

  • SAX parsing - Memory-efficient event-driven XML processing

  • Ruby-idiomatic - Natural, expressive API for XML manipulation

  • High performance - Efficient node mapping and adapter optimization

  • Thread-safe - Safe for concurrent operations

  • Complete node support - Handle all XML node types

Quick example

require 'moxml'

# Parse XML
doc = Moxml.new.parse('<library><book id="1">Ruby</book></library>')

# Query with XPath
books = doc.xpath('//book[@id="1"]')
puts books.first.text  # => "Ruby"

# Modify content
books.first.text = 'Advanced Ruby'
books.first['edition'] = '2nd'

# Output formatted XML
puts doc.to_xml(indent: 2)

Getting started

Choose your path:

Installation

Install Moxml and choose an XML adapter

Tutorials

Step-by-step guides to learn Moxml

Guides

Task-oriented documentation for common operations

Adapters

Learn about supported XML libraries

Supported adapters

Adapter Best for Performance

Nokogiri

Industry standard, wide compatibility

Fast

LibXML

Alternative to Nokogiri, full features

Very Fast

Oga

Pure Ruby, no C extensions

Fast

REXML

Standard library, maximum portability

Medium

Ox

Maximum speed, simple documents

Very Fast

HeadedOx

Fast parsing + comprehensive XPath 1.0 (99.20% pass rate)

Very Fast

Why Moxml?

Consistent API

Write once, run with any XML library. Switch adapters without changing your code.

Full XPath support

Powerful querying with namespace awareness across all adapters.

Modern design

Clean, Ruby-idiomatic interface that feels natural to use.

Production ready

Comprehensive error handling, thread safety, and performance optimization.

License

Moxml is released under the Ribose 3-Clause BSD License.

Copyright (c) 2025 Ribose Inc.