Ruby Way processing RSS and Atom

Source: Internet
Author: User
Tags require versions

1 RSS Standard Library

RSS is xml-based, so you can simply parse it as an XML. But, in fact, he has a higher level of proprietary parsers to parse him out. The standard of RSS is also very confusing.

He has a lot of inconvenience, is the standard version of the incompatibility, RSS has 0.9, 1.0, and 2.0 version. RSS versions, like making hot dogs, are some of the details that you don't want to know unless you must know.

Ruby has a standard RSS library that contains 0.9, 1.0, and 2.0 versions of the standard. As seamless as possible between different versions. If you don't specify a version, the library will test the version as much as possible.

Look at the example below where we get the feed from http://marsdrive.com:

Require ' RSS '
require ' Open-uri '
url = ' http://www.marstoday.com/rss/mars.xml '
open (URL) do |h|
RESP = h.read Result
= RSS::P arser.parse (resp,false)
puts "Channel: #{result.channel.title}"
Result.ite Ms.each_with_index do |item,i|
i + 1
puts "#{i} #{item.title}"
End

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.