Monday, September 21, 2009

XML Parsing in Ruby using Happy Mapper

Part of my job consists in getting a lot of data from different sources. Whether it's a SOAP or REST webservice, a TCP Socket, or simply files on a FTP, most of this data is in XML format.

There are different libraries to parse XML in Ruby. We used to do with XML Object, but the resulting code is really difficult to read and maintain. We prefer Happy Mapper.

It is an XML to object mapping library. You can find the source on Github. I also created a fork to add support for text node in mapping objects. It also includes the changes from David Bolton.

The resulting code is very readable and easy to maintain... and the library can be used in most cases. It's also quite fast since it uses XML Object for the actual parsing. Examples are in the source tree, and the source itself is quite short and easy to understand.

Enjoy easy and happy XML parsing! :)

No comments:

Post a Comment

Post a Comment