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
|
# File 'lib/douban/note.rb', line 28
def initialize(doc)
doc = REXML::Document.new(doc).root unless doc.kind_of?(REXML::Element)
doc = doc.root if doc.kind_of?(REXML::Document)
title=REXML::XPath.first(doc,"./title")
@title=title.text if title
published=REXML::XPath.first(doc,"./published")
@published=published.text if published
updated=REXML::XPath.first(doc,"./updated")
@updated=updated.text if updated
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
content=REXML::XPath.first(doc,"./content")
@content=content.text if content
summary=REXML::XPath.first(doc,"./summary")
@summary=summary.text if summary
author=REXML::XPath.first(doc,"./author")
@author=Author.new(author.to_s) if author
end
|