Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A generic swappable back-end for XML parsing
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Lots of Ruby libraries utilize XML parsing in some form, and everyone has their favorite XML library. In order to best support multiple XML parsers and libraries, multi_xml is a general-purpose swappable XML backend library. You use it like so:

require 'multi_xml'

MultiXml.engine = :nokogiri
MultiXml.parse('<tag>This is the contents</tag>') # parsed using Nokogiri

MultiXml.engine = :rexml
MultiXml.engine = MultiJson::Engines::Rexml # equivalent to previous line
MultiXml.parse('<tag>This is the contents</tag>') # parsed using REXML

The engine setter takes either a symbol or a class (to allow for custom XML parsers) that responds to .parse at the class level.

MultiXML tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered by speed. First LibXML, then Nokogiri, then Hpricot, then REXML.


MultiXML was inspired by MultiJSON.

Submitting Patches

  1. Fork the project.

  2. Commit your feature or bug fix.

  3. Add tests for it. This is important so it doesn't break in the future.

  4. Do not mess with gemspec, version, or history. (If you want to have your own version, that's fine, but please do so in a separate commit.)

  5. Submit a pull request. Bonus points for topic branches.


Copyright © 2010 Erik Michaels-Ober. See LICENSE for details.

Something went wrong with that request. Please try again.