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 |
|---|---|---|
Industry standard, wide compatibility | Fast | |
Alternative to Nokogiri, full features | Very Fast | |
Pure Ruby, no C extensions | Fast | |
Standard library, maximum portability | Medium | |
Maximum speed, simple documents | Very Fast | |
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.