XML in Ruby (or C++?)

Dear Ruby users,

I am (still) ignorant about Ruby, but, from the very few things I
read, it seems a very nice language. I would like to know some
opinions regarding Ruby’s suitability to parse XML files into an
internal Ruby representation so that they can be manipulated by Ruby
code and then written down to a new XML file.
Is it a good idea to do it in Ruby? What about efficiency? Should I do
it with C++ (with lots of templates ;-|) ? I already know quite a bit
(?) of C++ and that is the reason why I am also considering it.

Thanks a lot in advance for any opinions. I need them!

Joao

I would suggest that you look at xml-simple on RAA
(http://raa.ruby-lang.org/, direct link:
http://www.maik-schmidt.de/projects/xml-simple/). It is based on top of
REXML (pure Ruby xml parser) that transforms an XML input into a ruby
hash. It is extremely easy to manipulate and the resulting hash can be
easily dumped back to XML.

I am not sure about performance, however I do not believe it should be
an issue.

Gennady.

···

On Tuesday, July 29, 2003, at 07:17 PM, Joao Barros wrote:

Dear Ruby users,

I am (still) ignorant about Ruby, but, from the very few things I
read, it seems a very nice language. I would like to know some
opinions regarding Ruby’s suitability to parse XML files into an
internal Ruby representation so that they can be manipulated by Ruby
code and then written down to a new XML file.
Is it a good idea to do it in Ruby? What about efficiency? Should I do
it with C++ (with lots of templates ;-|) ? I already know quite a bit
(?) of C++ and that is the reason why I am also considering it.

Thanks a lot in advance for any opinions. I need them!

Joao

There are several XML parsing libraries for Ruby; the one which seems most
popular (and has been integrated into Ruby-1.8.0, which should be finally
released in the next day or so) is called REXML.

I think you should try it - it will be about 100 times easier than writing
the equivalent C++ code :slight_smile:

Speed is something you’ll have to try out for your application. If you are
parsing multi-megabyte XML files it might be an issue, but in the
applications I use it it’s not a problem at all.

Regards,

Brian.

···

On Wed, Jul 30, 2003 at 11:17:59AM +0900, Joao Barros wrote:

I am (still) ignorant about Ruby, but, from the very few things I
read, it seems a very nice language. I would like to know some
opinions regarding Ruby’s suitability to parse XML files into an
internal Ruby representation so that they can be manipulated by Ruby
code and then written down to a new XML file.
Is it a good idea to do it in Ruby? What about efficiency? Should I do
it with C++ (with lots of templates ;-|) ? I already know quite a bit
(?) of C++ and that is the reason why I am also considering it.

Thanks a lot in advance for any opinions. I need them!

If you find performance to be an issue with the Ruby-only based parsers,
then see what you can do with Sean Chittenden’s libxml package for Ruby.
It wraps libxml2 and is therefore fast and full-featured. The Ruby API
to libxml2 is quite similar to the excellent REXML API. What it lacks
in documentation, it makes up for in features.

That said, REXML has no library dependencies and works very well if you
don’t need a validating parser.

···

On Jul 30, Joao Barros wrote:

Dear Ruby users,

I am (still) ignorant about Ruby, but, from the very few things I
read, it seems a very nice language. I would like to know some
opinions regarding Ruby’s suitability to parse XML files into an
internal Ruby representation so that they can be manipulated by Ruby
code and then written down to a new XML file.
Is it a good idea to do it in Ruby? What about efficiency? Should I do
it with C++ (with lots of templates ;-|) ? I already know quite a bit
(?) of C++ and that is the reason why I am also considering it.

Thanks a lot in advance for any opinions. I need them!

Joao


---------------------------------------------- | --------------------------
Brett Williams | (970) 288-0475

Agilent Technologies brett_williams@agilent.com