// Copyright 2005 by Omar Al Zabir. All rights are reserved.
//
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
//
// website http://www.oazabir.com, email OmarAlZabir@gmail.com, msn oazabir@hotmail.com
using System;
using System.Xml;
using System.Collections;
namespace RSSCommon{
public enum RssTypeEnum
{
Unknown,
RSS,
Atom
}
/// <summary>
/// Represents an RSS Channel
/// </summary>
public class RssChannel
{
public string Title;
public string Description;
public string Link;
public RssTypeEnum Type = RssTypeEnum.RSS;
public IList Feeds;
public void WriteHeader( XmlWriter writer )
{
if( RssTypeEnum.RSS == this.Type )
{
writer.WriteStartElement("rss");
writer.WriteAttributeString("version", "2.0");
writer.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
writer.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/");
writer.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/");
writer.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/");
writer.WriteAttributeString("xmlns:content", "http://purl.org/rss/1.0/modules/content/" );
}
else if( RssTypeEnum.Atom == this.Type )
{
writer.WriteStartElement("feed");
writer.WriteAttributeString("version", "0.3");
writer.WriteAttributeString("xmlns", "http://purl.org/atom/ns#");
}
else
{
writer.WriteStartElement( "channel" );
}
}
public void WriteStartElement( XmlWriter writer )
{
writer.WriteStartElement("channel");
writer.WriteElementString( "title", this.Title );
writer.WriteElementString( "description", this.Description );
writer.WriteElementString( "link", this.Link );
}
public void WriteEndElement( XmlWriter writer )
{
writer.WriteEndElement();
}
public void WriteFooter( XmlWriter writer )
{
writer.WriteEndElement();
}
}
}
|