This project is archived and is in readonly mode.

#3636 ✓committed
Willem van Bergen

[PATCH] SAX-based backend for XmlMini, using Nokogiri and/or LibXML

Reported by Willem van Bergen | December 30th, 2009 @ 03:28 PM

I wrote a SAX-based backend for XmlMini using Nokogiri. It is way faster and more memory-efficient than the default Nokogiri backend. Results of the benchmark at http://github.com/stepheneb/rails_hash_from_xml :

Rehearsal -----------------------------------------------
rexml        24.050000   0.140000  24.190000 ( 24.386877)
libxml        0.750000   0.020000   0.770000 (  0.784579)
nokogiri     10.840000   0.090000  10.930000 ( 11.222716)
nokogirisax   1.060000   0.010000   1.070000 (  1.121834)
------------------------------------- total: 36.960000sec

                  user     system      total        real
rexml        24.110000   0.110000  24.220000 ( 24.597668)
libxml        0.460000   0.010000   0.470000 (  0.456876)
nokogiri     10.480000   0.030000  10.510000 ( 10.547534)
nokogirisax   0.940000   0.000000   0.940000 (  0.933274)

Not as fast as the LibXML backend, but that one is not fully compatible, and based on abandonware ;-)

Moreover, the SAX document that is being used to build the hash can be switched, which is nice if you want to "fix" some faulty XML that is being sent to your application. This is why I wrote this backend in the first place.

I wrote the patch against the 2-3-stable branch, but it applies cleanly to the master branch. All tests run OK when I switch the default REXML backend for this implementation.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>