libxml-ruby provides Ruby bindings to the libxml2 C library, offering fast XML parsing, manipulation, and validation capabilities. As one of the oldest and most widely deployed XML processors, libxml2 brings proven reliability and performance to Ruby applications needing comprehensive XML support. The gem exposes libxml2's full feature set including DOM parsing, SAX parsing, XPath queries, XSLT transformations, and schema validation.
The library offers multiple parsing strategies: DOM parsing for in-memory document manipulation, SAX parsing for memory-efficient streaming of large documents, and Reader (pull parsing) for forward-only document traversal. It includes complete XPath 1.0 support for querying documents, DTD and XML Schema validation, and XSLT 1.0 transformation capabilities. libxml-ruby handles character encoding conversions, namespace management, and provides detailed error reporting. The C extension delivers performance significantly faster than pure Ruby XML libraries, particularly important for processing large documents or high-throughput XML operations.
libxml-ruby is essential for applications requiring robust XML processing beyond basic parsing, such as SOAP clients, RSS/Atom feed processors, XML-based configuration systems, and data interchange with XML-based APIs. It's particularly valuable when XML schema validation is required, when processing very large XML files efficiently, or when XSLT transformations are needed. While Nokogiri has become more popular for HTML and basic XML needs, libxml-ruby remains relevant for applications requiring direct libxml2 access or specific XML processing features.
gem install libxml-ruby Run this gem instantly in your browser without any installation:
Open in RunRuby.dev →All 71 versions available for installation