2 // RSS.cs: Some utility classes to generate RSS feeds
4 // (C) 2002 Miguel de Icaza (miguel@gnu.org)
16 XmlText title, link, description, pubdate;
18 public Item (XmlDocument doc, XmlNode item)
24 XmlText MakeTextElement (string name)
26 XmlNode node = doc.CreateElement (name);
27 XmlText text = doc.CreateTextNode ("");
29 item.AppendChild (node);
30 node.AppendChild (text);
45 title = MakeTextElement ("title");
60 link = MakeTextElement ("link");
65 public string Description {
67 if (description == null)
70 return description.Value;
74 if (description == null)
75 description = MakeTextElement ("description");
76 description.Value = value;
80 public string PubDate {
90 pubdate = MakeTextElement ("pubDate");
91 pubdate.Value = value;
96 public class Channel {
99 XmlText title, link, description, language, pubDate, lastBuildDate;
100 XmlText managingEditor, webMaster;
102 XmlText MakeTextElement (string name)
104 XmlNode node = doc.CreateElement (name);
105 XmlText text = doc.CreateTextNode ("");
107 channel.AppendChild (node);
108 node.AppendChild (text);
113 public Channel (XmlDocument doc, XmlNode node)
118 title = MakeTextElement ("title");
119 link = MakeTextElement ("link");
120 description = MakeTextElement ("description");
123 public Item NewItem ()
125 XmlNode node = doc.CreateElement ("item");
128 channel.AppendChild (node);
129 item = new Item (doc, node);
134 public string Title {
154 public string Description {
156 return description.Value;
160 description.Value = value;
164 #region Optional Values
165 public string ManagingEditor {
167 if (managingEditor == null)
170 return managingEditor.Value;
174 if (managingEditor == null)
175 managingEditor = MakeTextElement ("managingEditor");
177 managingEditor.Value = value;
181 public string WebMaster {
183 if (webMaster == null)
186 return webMaster.Value;
190 if (webMaster == null)
191 webMaster = MakeTextElement ("webMaster");
192 webMaster.Value = value;
196 public string PubDate {
201 return pubDate.Value;
206 pubDate = MakeTextElement ("pubDate");
207 pubDate.Value = value;
211 public string LastBuildDate {
213 if (lastBuildDate == null)
216 return lastBuildDate.Value;
220 if (lastBuildDate == null)
221 lastBuildDate = MakeTextElement ("lastBuildDate");
222 lastBuildDate.Value = value;
226 public string Language {
228 if (language == null)
231 return language.Value;
235 if (language == null)
236 language = MakeTextElement ("language");
237 language.Value = value;
247 const string rss_base =
248 "<?xml version=\"1.0\"?> <rss version=\"0.92\"></rss>";
252 doc = new XmlDocument ();
254 doc.LoadXml (rss_base);
255 rss = doc.DocumentElement;
258 public Channel NewChannel (string title, string url)
260 XmlNode node = doc.CreateElement ("channel");
263 rss.AppendChild (node);
264 c = new Channel (doc, node);
269 public XmlDocument XmlDocument {