Created
June 26, 2009 12:32
-
-
Save madx/136445 to your computer and use it in GitHub Desktop.
Using Xup to create a RSS feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:.unshift File.join(File.dirname(__FILE__), 'lib') | |
require 'time' | |
require 'xup' | |
require 'xup/modules/xml' | |
class Xup::Document::RSS < Xup::Context | |
use Xup::Modules::XML | |
end | |
context = Xup::Document::RSS.new do | |
instruct! :xml, :version => "1.0", :encoding => "UTF-8" | |
tag! :rss, '', :version => "2.0" do | |
tag! :channel do | |
tag! :title, "Yapok" | |
tag! :description, "Yapok" | |
tag! :link, "http://yapok.org/" | |
tag! :item do | |
tag! :title, "An item" | |
tag! :link, "http://yapok.org/post/an_item" | |
tag! :description, "Contents" | |
tag! :pubDate, Time.now.httpdate | |
tag! :guid, "http://yapok.org/post/an_item" | |
end | |
end | |
end | |
end | |
puts context.buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<rss version="2.0"> | |
<channel> | |
<title>Yapok</title> | |
<description>Yapok</description> | |
<link>http://yapok.org/</link> | |
<item> | |
<title>An item</title> | |
<link>http://yapok.org/post/an_item</link> | |
<description>Contents</description> | |
<pubDate>Fri, 26 Jun 2009 12:32:32 GMT</pubDate> | |
<guid>http://yapok.org/post/an_item</guid> | |
</item> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment