26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/douban/miniblog.rb', line 26
def initialize(atom)
doc = case atom
when REXML::Document then atom.root
when REXML::Element then atom
else REXML::Document.new(atom).root
end
title=REXML::XPath.first(doc,"./title")
@title=title.text if title
published=REXML::XPath.first(doc,"./published")
@published=published.text if published
REXML::XPath.each(doc,"./link") do |link|
@link||={}
@link[link.attributes['rel']]=link.attributes['href']
end
id=REXML::XPath.first(doc,"./id")
@id=id.text if id
REXML::XPath.each(doc,"./db:attribute") do |attr|
@attribute||={}
@attribute[attr.attributes['name']]=attr.text
end
category=REXML::XPath.first(doc,"./category")
if category
@category={}
@category['term']=category.attributes['term']
@category['scheme']=category.attributes['scheme']
end
content=REXML::XPath.first(doc,"./content")
@content=content.text if content
author=REXML::XPath.first(doc,"./author")
@author=Author.new(author.to_s) if author
end
|