FastXML 0.1.93


A long while ago I started work on a simple hpricot-like interface to libxml for ruby. I've finally push out an initial version, and it's available on the gem servers now just gem install fastxml. You can find the code on github.

Here's a sample of it's usage: require 'fastxml' doc = FastXml( open( 'test.xml' ) ) (doc/"//a").each { |a| puts a.attr['href'] }

Here's a simple synthetic benchmark. We just load a simple xml file attempt to do an xpath search. It's worth noting that the regular libxml binding is very speedy, because it doesn't actually match anything. Libxml annoyingly want's all xpath queries namespace qualified, that doesn't work out well if you have no root namespace.

(in /Users/segfault/Devel/fastxml)
ruby ./benchmarks/speedtest.rb
                     user     system      total        real
fastxml.new      0.000000   0.000000   0.000000 (  0.001211)
fastxml.to_s     0.000000   0.000000   0.000000 (  0.000537)
fastxml.search   0.000000   0.000000   0.000000 (  0.000315)

hpricot.new      0.020000   0.000000   0.020000 (  0.021583)
hpricot.to_s     0.000000   0.000000   0.000000 (  0.002366)
hpricot.search   0.000000   0.000000   0.000000 (  0.000462)

libxml.new       0.000000   0.000000   0.000000 (  0.001274)
libxml.to_s      0.000000   0.000000   0.000000 (  0.000421)
libxml.search    0.000000   0.000000   0.000000 (  0.000175)

REXML.new        0.020000   0.000000   0.020000 (  0.018574)
REXML.to_s       0.010000   0.000000   0.010000 (  0.003909)
REXML.xpath      0.000000   0.000000   0.000000 (  0.001838)