Created
November 7, 2010 09:33
-
-
Save aquajach/666021 to your computer and use it in GitHub Desktop.
REXML example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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