In case you need to populate your database with some fake data from a XML file or you are creating some ETL processes where you want to map XML to RubyObjects, xml-mapping gem can help you achieving this task.

class Product
  include XML::Mapping

  text_node :ref, "@reference"
  text_node :desc, "Description"
  numeric_node :quantity, "Quantity"
  numeric_node :unit_price, "UnitPrice"

  def total_price
    quantity*unit_price
  end
end