Ruby xml parser opinions?

I’m revisiting an app that uses libxml for xml work. Wondering if
anyone has opinions on what is the best available XML parser for Ruby?

REXML seems to get trashed at every opportunity. Hpricot is getting
some good press, but is it better than libxml? Most posts I’ve seen
when someone chooses hpricot over libxml is because they are running
on Windows.

Found this post “http://yomi.at/archives/19” which seems recent and
clearly shows libxml as the parser of choice when speed is the primary
consideration.

Any thoughts?

Andy K. wrote:

I’m revisiting an app that uses libxml for xml work. Wondering if
anyone has opinions on what is the best available XML parser for Ruby?

REXML seems to get trashed at every opportunity. Hpricot is getting
some good press, but is it better than libxml? Most posts I’ve seen
when someone chooses hpricot over libxml is because they are running
on Windows.

Found this post “http://yomi.at/archives/19” which seems recent and
clearly shows libxml as the parser of choice when speed is the primary
consideration.

Any thoughts?

Hpricot is awesome, but if I need to have anything that parses
namespaces, I use REXML. I don’t like REXML at all, but it handles
namespaces well enough. Hpricot is so easy to use you have ever used
CSS that its hard not to recommend.

On Apr 3, 2008, at 1:00 PM, Andy K. wrote:

consideration.

Any thoughts?

depends entirely on your use case

  • skimming a small amount of data from nested nodes -> hpricot

  • parsing a hierarchy where attrs and relationship of parent <-> child
    is important -> rexml

a @ http://codeforpeople.com/

2008/4/3, Andy K. [email protected]:

I’m revisiting an app that uses libxml for xml work. Wondering if
anyone has opinions on what is the best available XML parser for Ruby?

REXML seems to get trashed at every opportunity.

It may seem so. But keep in mind that if something does not work as
expected people will shout loudly - while all those that are satisfied
are usually quietly enjoying it. Whenever I have to do XML in Ruby I
use REXML. Granted, I don’t have large files to handle right now but
if, I would try using REXML’s stream parser instead of doing anything
else.

Found this post “http://yomi.at/archives/19” which seems recent and
clearly shows libxml as the parser of choice when speed is the primary
consideration.

Probably true, but with the stream based approach you can also get
more out of REXML. I like the fact that it does not require a binary
extension and is part of the standard install. Ultimate speed for me
is not as important as availability and portability of my scripts.

YMMV

Kind regards

robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs