Speed up xml parsing in ActiveSupport

01 April 2011


Browsing through Rails source code today in one of my occasional Rails edge source explorations I stubled upon an interesting comment in xml_mini.rb in active support:

Screen_shot_2011-04-01_at_17

What this comment says is that you can require and use the faster libxml-ruby gem instead of the default REXML XML processor. What you have to do is require the gem in your Gemfile:

gem 'libxml-ruby', '=0.9.7'

and somewhere in your code (probably an initializer) put this line:

ActiveSupport::XmlMini.backend = 'LibXML'

Checkout a post I wrote some time ago for a similar hint on how to speed up JSON parsing in Rails.


blog comments powered by Disqus