2 // RSS.cs: Some utility classes to generate RSS feeds
4 // (C) 2002 Miguel de Icaza (miguel@gnu.org)
16 XmlText title, link, description;
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;
81 public class Channel {
84 XmlText title, link, description, language, pubDate, lastBuildDate;
85 XmlText managingEditor, webMaster;
87 XmlText MakeTextElement (string name)
89 XmlNode node = doc.CreateElement (name);
90 XmlText text = doc.CreateTextNode ("");
92 channel.AppendChild (node);
93 node.AppendChild (text);
98 public Channel (XmlDocument doc, XmlNode node)
103 title = MakeTextElement ("title");
104 link = MakeTextElement ("link");
105 description = MakeTextElement ("description");
108 public Item NewItem ()
110 XmlNode node = doc.CreateElement ("item");
113 channel.AppendChild (node);
114 item = new Item (doc, node);
119 public string Title {
139 public string Description {
141 return description.Value;
145 description.Value = value;
149 #region Optional Values
150 public string ManagingEditor {
152 if (managingEditor == null)
155 return managingEditor.Value;
159 if (managingEditor == null)
160 managingEditor = MakeTextElement ("managingEditor");
162 managingEditor.Value = value;
166 public string WebMaster {
168 if (webMaster == null)
171 return webMaster.Value;
175 if (webMaster == null)
176 webMaster = MakeTextElement ("webMaster");
177 webMaster.Value = value;
181 public string PubDate {
186 return pubDate.Value;
191 pubDate = MakeTextElement ("pubDate");
192 pubDate.Value = value;
196 public string LastBuildDate {
198 if (lastBuildDate == null)
201 return lastBuildDate.Value;
205 if (lastBuildDate == null)
206 lastBuildDate = MakeTextElement ("lastBuildDate");
207 lastBuildDate.Value = value;
211 public string Language {
213 if (language == null)
216 return language.Value;
220 if (language == null)
221 language = MakeTextElement ("language");
222 language.Value = value;
232 const string rss_base =
233 "<?xml version=\"1.0\"?> <rss version=\"0.92\"></rss>";
237 doc = new XmlDocument ();
239 doc.LoadXml (rss_base);
240 rss = doc.DocumentElement;
243 public Channel NewChannel (string title, string url)
245 XmlNode node = doc.CreateElement ("channel");
248 rss.AppendChild (node);
249 c = new Channel (doc, node);
254 public XmlDocument XmlDocument {