class LiveJournal::Sync::CommentsXML::WithREXML
Public Instance Methods
parse(data)
click to toggle source
# File lib/livejournal/comments-xml.rb, line 67 def parse(data) doc = REXML::Document.new(data) root = doc.root root.elements.each('maxid') { |e| @maxid = e.text.to_i } root.elements.each('comments/comment') do |e| id = e.attributes['id'].to_i comment = @comments[id] || Comment.new CommentsXML::load_comment_from_attrs(comment, e.attributes) e.elements.each('subject') { |s| comment.subject = s.text } e.elements.each('body') { |s| comment.body = s.text } e.elements.each('date') { |s| comment.time = Time::xmlschema s.text } @comments[id] = comment end root.elements.each('usermaps/usermap') do |e| id = e.attributes['id'].to_i user = e.attributes['user'] @usermap[id] = user end end