Skip to content

Instantly share code, notes, and snippets.

@aquajach
Created November 7, 2010 09:33
Show Gist options
  • Save aquajach/666021 to your computer and use it in GitHub Desktop.
Save aquajach/666021 to your computer and use it in GitHub Desktop.
REXML example
xml = File.read('timeline.xml')
puts Benchmark.measure {
doc, statuses = REXML::Document.new(xml), []
doc.elements.each('statuses/status') do |s|
h = {:user => {}}
%w[created_at id text source truncated in_reply_to_status_id in_reply_to_user_id favorited].each do |a|
h[a.intern] = s.elements[a].text
end
%w[id name screen_name location description profile_image_url url protected followers_count].each do |a|
h[:user][a.intern] = s.elements['user'].elements[a].text
end
statuses << h
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment