April 06, 2006

Atom 1.0 parser for Ruby

I've been looking for a Ruby library for parsing Atom 1.0. The only one I could find was FeedTools. Unfortunately, it's intended to be a universal feed-parsing library and not quite what I need.

As a result, I decided to build my own. The project is hosted at RubyForge and the source code is available under the MIT license.

It is still in its early stages, so don't expect much at this point. So far, it understands most atom:* elements and attributes but doesn't perform validation.

The interface is fairly simple. For example, you can do this:


require 'atom'
require 'net/http'
require 'uri'

str = Net::HTTP::get(URI::parse('http://blog.ning.com/atom.xml'))
feed = Atom::Feed.new(str)

feed.entries.each { |entry|
puts "'#{entry.title}' by #{entry.authors.first.name} on #{entry.published.strftime('%m/%d/%Y')}"
}


Give it a try, play with it. Comments are welcome!

Labels:

14 Comments:

Blogger 道喜技术日记 said...

How to get Link href value?

February 04, 2007 3:29 PM  
Blogger 道喜技术日记 said...

entry.links[0]

February 04, 2007 3:47 PM  
Blogger Tim Morgan said...

This is exactly what I was looking for! This, combined with the standard Ruby RSS parser, should give me everything I need to grab feeds I think. You rock!

August 07, 2007 8:09 AM  
Blogger malikiqbal said...

is it possible to generate Google apps atom feed?

If yes then what kind changes i nned to do with this library or need to embed any other library with this.

December 12, 2007 10:42 PM  
Blogger malikiqbal said...

This comment has been removed by the author.

December 12, 2007 10:43 PM  
Blogger tbeauvais said...

Hi, is there a way to get at extension elements in the Atom feed? For example <openSearch:totalResults>

July 11, 2008 1:00 PM  
Blogger Ashish said...

How do I get the value of src from the following?
entry....
.
.
.
content type="text/plain"
xml:lang="en"
src="http://...."
/content
/entry
I tried entry.content.src, entry.content['src']. But both didn't work

November 03, 2008 5:54 AM  
Blogger Martin said...

entry.content.src should work. Can you send me your complete test case so that I can debug it here?

November 03, 2008 8:17 AM  
Blogger Ashish said...

Hi Martin,
I did 'inspect' on the feed returned by Atom. The value of src goes as the value of href of the third link in the entry. Not sure why that happens but am able to access src using entry.links[2].href

November 03, 2008 10:25 PM  
Anonymous Anonymous said...

You know ,I have some priston tale Gold,and my friend also has some priston tale Money,do you kouw they have the same meaning,I just want to buy priston tale Gold,because there are many cheap priston tale GoldYou know ,I have some wonderland Gold,and my friend also has some wonderland online Gold,do you kouw they have the same meaning,Both of them can be called
wonderland money,I just want to
buy wonderland Gold,because there are many
cheap wonderland online Gold

April 14, 2009 5:58 PM  
Anonymous Anonymous said...

I can get Pirates of the Burning Sea Gold cheaply,
Yesterday i want to buy potbs goldfor my brother.
i hope him like it. i will buy potbs Doubloon for him
as birthday present. i like the potbs money very much.
I usuallybuy potbs Doubloon and keep it in my store.

May 04, 2009 5:27 PM  
Blogger Unknown said...

wow power levelingpower levelingwow power levelpowerlevelingpower levelwow powerlevelingwow goldbuy wow goldcheap wow gold

May 15, 2009 6:23 AM  
Blogger Adi said...

Pandeglang is one of many places in Indonesia are eligible for tourist destination.
Kenali dan Kunjungi Objek Wisata di Pandeglang Objek Wisata di Pandeglang Kenali dan Kunjungi Objek Wisata di Pandeglang Pantai Carita Seni Saman Rampak Bedug

October 29, 2009 11:05 PM  
Anonymous Anonymous said...

Clothing has always been a thing that has been given a great importance by human beings. It displays the attitude that the people exhibit.
ed hardy clothes
ed hardy shirts
Lots of brands have been existent in the clothing industry and a famous one among them is the Ed hardy clothing brand.
ed hardy jackets
ed hardy hoodies
The brand got its name from the famous American tattoo artist Ed Hardy. He was a very famous tattoo artist and has published many books on tattooing techniques.
ed hardy boots
ed hardy polo shirts
But his tattooing turned into a brand by the efforts of a company called Christian Audiger. This company was a very famous and very powerful company in the field of clothing.
ed hardy shoes
ed hardy jeans
They felt that it would be appropriate to create a brand called Ed hardy and use Hardy's art as the main selling point for the brand. This venture had turned out to be a very successful one and Ed hardy clothing is one of the most famous brands in the clothing industry.
ed hardy outerwear
ed hardy long sleeve shirts
The brand became very famous because it was worn by many famous celebrities like Madonna, Britney spears and also Sylvester Stallone.
ed hardy bags
ed hardy uggr boots
The brand has clothes for men, women, and kids. They have also diversified their business by having a lot of accessories to support their clothing business.
ed hardy love kills slowly shirts
ed hardy love kills slowly shoes
ed hardy love kills slowly boots
for men they have a variety of products such as active wear, denim, outwear, swim trucks, sweaters, t-shirts, tops etc.
ed hardy trousers
ed hardy mens
the accessories include things such as belts, caps, scarves, shoes, socks, jeweler, sunglasses, ties and even wallets.
The art works is a unique combination of American and Japanese cultures. The unique selling proposition of the brand is the way in which the company has used the art works of Ed hardy.
ed hardy womens
ed hardy t shirts
ed hardy sunglasses

December 15, 2009 4:51 PM  

Post a Comment

<< Home