Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (17 sloc) 0.774 kb
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'happymapper')
file_contents = File.read(dir + '/../spec/fixtures/current_weather.xml')
class CurrentWeather
include HappyMapper
tag 'ob'
namespace 'aws'
element :temperature, Integer, :tag => 'temp'
element :feels_like, Integer, :tag => 'feels-like'
element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
end
CurrentWeather.parse(file_contents).each do |current_weather|
puts "temperature: #{current_weather.temperature}"
puts "feels_like: #{current_weather.feels_like}"
puts "current_condition: #{current_weather.current_condition}"
puts "current_condition.icon: #{current_weather.current_condition.icon}"
end
Jump to Line
Something went wrong with that request. Please try again.