This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Parsing Ta-da Lists
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Ruby is becoming the language for conversion of idea-to-task, for recording and processing notes. We’re all sitting here watching 37signals and DHH pour out streams of Rails applications for organizing your thoughts.
Tobias Luetke demostrates how simple it is to parse out your Ta-da lists with Ruby’s built-in XML reader:
xml = Document.new(body)
self.items = []
XPath.each(xml, "//item/") do |elem|
task = Task.new
task.title = XPath.match(elem, "title/text()").to_s
task.date = XPath.match(elem, "pubDate/text()").to_s
task.link = XPath.match(elem, "link/text()").to_s
items << task
end