From: Phlip Date: 2008-07-20T09:34:52+09:00 Subject: Re: XML parser C�dric H. wrote: > I'm looking for some information about the xml libraries available in > Ruby. > > I've read a few blog post about the pro's and con's of REXML and > Libxml but I still have some questions : > > - as I understand it REXML is part of ruby standard library and so is > included in ruby distribution ? Yes. It's also widely acknowledged as very slow. The RE stands for Regular Expressions, which are only fast when used carefully. Basing an entire parser on them tends to abuse them. This blog show how to spot-check compliance issues in the three leading Ruby XML parsers: http://www.oreillynet.com/onlamp/blog/2007/08/assert_hpricot_1.html > - libxml is a wrapper for gnome libxml and must be installed and > compiled with gem ? Ordinarily, that process would be mostly harmless. You may already have libxml2-dev, if you have a GNU platform such as Ubuntu or CygWin. However, the current libxml-ruby has a nasty bug. First, it sprays lots of No definition for ruby_xml_parser_context_options_get into the console. Then it refuses to install the libxml_so.so file that it just created. I don't know this bug's status, but because my assert_xpath works best with libxml, I must overcome it whenever we build a new workstation at work! Sometimes I must manually copy its executables into Ruby's paths... (Our production code does not use libxml - only the test code.) I just tried to install while writing this post, and 0.8.1 might have worked on Ubuntu. > - is libxml really a full validating and compliant parser ? I suspect it's the reference implementation for XML. It certainly takes every DOCTYPE and schema very seriously! Better, it actually forgives some errors and keeps working, unlike REXML > - how do you use xslt in Ruby ? do you use http://raa.ruby-lang.org/project/ruby-xslt/ > or http://rubyforge.org/projects/libxsl/ (if I'm right the second one > is part of libxml ? ) > > As you see I'm lost and I would really appreciate your help or some > comprehensive post about xml processing in ruby . Sorry! I was knocking 'em down, and you lost me at XSLT. In a pinch, I would pipe text thru xsltproc, and not worry about deep language integration. XSLT is nothing but a big filter, so I thought you could use it without making an object out of it. -- Phlip