Skip to content


MIT 11 4 886
141.6 thousand (month) Jul 01 2011 2.14.18(15 days ago)
153 7 22 MIT
0.10.0(2 months ago) Mar 19 2010 23.2 thousand (month)

Ox is a Ruby gem that provides a simple and efficient way to parse and generate XML and JSON documents. It is built on top of the underlying C library libox, which is known for its speed and low memory usage. Ox provides a simple and intuitive API for parsing and generating XML and JSON documents, and it is widely used in the Ruby ecosystem for web scraping, web development, and data-gathering applications.

One of the main features of Ox is its ability to parse and generate XML and JSON documents with low memory usage. Ox uses a pull-based parsing strategy, which allows it to parse large documents without loading the entire document into memory, thus making it more efficient than other parsing libraries. Ox also provides a fast and efficient way of generating XML and JSON documents.

Ox also provides a variety of other features that can simplify the process of working with XML and JSON documents. It can automatically handle character encodings, it can parse and generate documents with minimal memory usage, and it can validate documents against a DTD or schema.

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

require 'ox'

class Sample
  attr_accessor :a, :b, :c

  def initialize(a, b, c)
    @a = a
    @b = b
    @c = c

# Create Object
obj =, "bee", ['x', :y, 7.0])
# Now dump the Object to an XML String.
xml = Ox.dump(obj)
# Convert the object back into a Sample Object.
obj2 = Ox.parse_obj(xml)
require 'happymapper'

xml = '<address>
  <country code="de">Germany</country>

# we can parse it as is:
address = HappyMapper.parse(ADDRESS_XML_DATA)
address.street # => Milchstrasse
address.housenumber # => 23
address.postcode # => 26131 # => Oldenburg # => de # => 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'

Alternatives / Similar