Skip to content

happymapper

152 7 23 MIT
0.10.1 (25 Oct 2025) Mar 19 2010 41.1 thousand (month)

Happymapper allows you to parse XML data and convert it quickly and easily into ruby data structures.

Happymapper maps XML structures to ruby data structures which then can be parsed for data using any other Ruby data tools. This also means, happymaker can convert XML to JSON as ruby data structures are easily exportable to JSON

Example Use


```ruby require 'happymapper'

xml = '

Milchstrasse 23 26131 Oldenburg Germany
'

we can parse it as is:

address = HappyMapper.parse(ADDRESS_XML_DATA) address.street # => Milchstrasse address.housenumber # => 23 address.postcode # => 26131 address.city # => Oldenburg address.country.code # => de address.country.content # => Germany

or define a structure

class Address include HappyMapper

tag 'address' element :street, String, tag: 'street' element :postcode, String, tag: 'postcode' element :housenumber, Integer, tag: 'housenumber' element :city, String, tag: 'city' element :country, String, tag: 'country' end Address.parse(xml) ```

Alternatives / Similar


ox
911 2.14.23 (2025-05-28 01:01:53 ago) Jul 01 2011 compare
225 4.2.0 (2021-09-09 05:37:36 ago) Aug 05 2009 compare

Other Languages

Was this page helpful?