//============================================================ // CLASS SUMMARY //============================================================ /// <summary> /// Provides example code for the RssFeed class. /// </summary> public static void ClassExample() { #region RssFeed RssFeed feed = new RssFeed(); feed.Channel.Title = "Dallas Times-Herald"; feed.Channel.Link = new Uri("http://dallas.example.com"); feed.Channel.Description = "Current headlines from the Dallas Times-Herald newspaper"; feed.Channel.Categories.Add(new RssCategory("Media")); feed.Channel.Categories.Add(new RssCategory("News/Newspapers/Regional/United_States/Texas", "dmoz")); feed.Channel.Cloud = new RssCloud("server.example.com", "/rpc", 80, RssCloudProtocol.XmlRpc, "cloud.notify"); feed.Channel.Copyright = "Copyright 2007 Dallas Times-Herald"; feed.Channel.Generator = "Microsoft Spaces v1.1"; RssImage image = new RssImage(new Uri("http://dallas.example.com"), "Dallas Times-Herald", new Uri("http://dallas.example.com/masthead.gif")); image.Description = "Read the Dallas Times-Herald"; image.Height = 32; image.Width = 96; feed.Channel.Image = image; feed.Channel.Language = new CultureInfo("en-US"); feed.Channel.LastBuildDate = new DateTime(2007, 10, 14, 17, 17, 44); feed.Channel.ManagingEditor = "[email protected] (Jim Lehrer)"; feed.Channel.PublicationDate = new DateTime(2007, 10, 14, 5, 0, 0); feed.Channel.Rating = "(PICS-1.1 \"http://www.rsac.org/ratingsv01.html\" l by \"[email protected]\" on \"2007.01.29T10:09-0800\" r (n 0 s 0 v 0 l 0))"; feed.Channel.SkipDays.Add(DayOfWeek.Saturday); feed.Channel.SkipDays.Add(DayOfWeek.Sunday); feed.Channel.SkipHours.Add(0); feed.Channel.SkipHours.Add(1); feed.Channel.SkipHours.Add(2); feed.Channel.SkipHours.Add(22); feed.Channel.SkipHours.Add(23); feed.Channel.TextInput = new RssTextInput("What software are you using?", new Uri("http://www.cadenhead.org/textinput.php"), "query", "TextInput Inquiry"); feed.Channel.TimeToLive = 60; feed.Channel.Webmaster = "*****@*****.**"; RssItem item = new RssItem(); item.Title = "Seventh Heaven! Ryan Hurls Another No Hitter"; item.Link = new Uri("http://dallas.example.com/1991/05/02/nolan.htm"); item.Description = "Texas Rangers pitcher Nolan Ryan hurled the seventh no-hitter of his legendary career on Arlington Appreciation Night, defeating the Toronto Blue Jays 3-0."; item.Author = "[email protected] (Joe Bob Briggs)"; item.Categories.Add(new RssCategory("sports")); item.Categories.Add(new RssCategory("1991/Texas Rangers", "rec.sports.baseball")); item.Comments = new Uri("http://dallas.example.com/feedback/1983/06/joebob.htm"); item.Enclosures.Add(new RssEnclosure(24986239L, "audio/mpeg", new Uri("http://dallas.example.com/joebob_050689.mp3"))); item.Guid = new RssGuid("http://dallas.example.com/1983/05/06/joebob.htm"); item.PublicationDate = new DateTime(2007, 10, 5, 9, 0, 0); item.Source = new RssSource(new Uri("http://la.example.com/rss.xml"), "Los Angeles Herald-Examiner"); feed.Channel.AddItem(item); #endregion }
public void ProcessWidth_IsCorrect() { string xml = "<width>222</width>"; var document = GenerateDocumentFromXML(xml); var image = new RssImage(); image = rss20Controller.ProcessElement(document, image); Assert.AreEqual("222", image.Width); }
public void ProcessHeight_IsCorrect() { string xml = "<height>400</height>"; var document = GenerateDocumentFromXML(xml); var image = new RssImage(); image = rss20Controller.ProcessElement(document, image); Assert.AreEqual("400", image.Height); }
/// <summary> /// Provides example code for the RssImage class. /// </summary> public static void ClassExample() { RssFeed feed = new RssFeed(); feed.Channel.Title = "Dallas Times-Herald"; feed.Channel.Link = new Uri("http://dallas.example.com"); feed.Channel.Description = "Current headlines from the Dallas Times-Herald newspaper"; RssImage image = new RssImage(new Uri("http://dallas.example.com"), "Dallas Times-Herald", new Uri("http://dallas.example.com/masthead.gif")); image.Description = "Read the Dallas Times-Herald"; image.Height = 32; image.Width = 96; feed.Channel.Image = image; }
/// <summary> /// Initializes the supplied <see cref="RssImage"/> using the specified <see cref="XPathNavigator"/> and <see cref="XmlNamespaceManager"/>. /// </summary> /// <param name="image">The <see cref="RssImage"/> to be filled.</param> /// <param name="navigator">The <see cref="XPathNavigator"/> used to navigate the image XML data.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> object used to configure the load operation.</param> /// <exception cref="ArgumentNullException">The <paramref name="image"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="navigator"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception> private static void FillImage(RssImage image, XPathNavigator navigator, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { //------------------------------------------------------------ // Validate parameters //------------------------------------------------------------ Guard.ArgumentNotNull(image, "image"); Guard.ArgumentNotNull(navigator, "navigator"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); //------------------------------------------------------------ // Attempt to extract image information //------------------------------------------------------------ XPathNavigator linkNavigator = navigator.SelectSingleNode("rss:link", manager); XPathNavigator titleNavigator = navigator.SelectSingleNode("rss:title", manager); XPathNavigator urlNavigator = navigator.SelectSingleNode("rss:url", manager); if (linkNavigator != null) { Uri link; if (Uri.TryCreate(linkNavigator.Value, UriKind.RelativeOrAbsolute, out link)) { image.Link = link; } } if (titleNavigator != null) { if (!String.IsNullOrEmpty(titleNavigator.Value)) { image.Title = titleNavigator.Value; } } if (urlNavigator != null) { Uri url; if (Uri.TryCreate(urlNavigator.Value, UriKind.RelativeOrAbsolute, out url)) { image.Url = url; } } SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(navigator, settings); adapter.Fill(image); }
/// <summary> /// Closes connection to file. /// </summary> /// <remarks> /// This method also releases any resources held while reading. /// </remarks> public void Close() { this.textInput = null; this.image = null; this.cloud = null; this.channel = null; this.source = null; this.enclosure = null; this.category = null; this.item = null; if (this.reader != null) { this.reader.Close(); this.reader = null; } this.elementText = null; this.xmlNodeStack = null; }
//============================================================ // CLASS SUMMARY //============================================================ /// <summary> /// Provides example code for the RssChannel class. /// </summary> public static void ClassExample() { #region RssChannel RssFeed feed = new RssFeed(); feed.Channel.Title = "Dallas Times-Herald"; feed.Channel.Link = new Uri("http://dallas.example.com"); feed.Channel.Description = "Current headlines from the Dallas Times-Herald newspaper"; feed.Channel.Categories.Add(new RssCategory("Media")); feed.Channel.Categories.Add(new RssCategory("News/Newspapers/Regional/United_States/Texas", "dmoz")); feed.Channel.Cloud = new RssCloud("server.example.com", "/rpc", 80, RssCloudProtocol.XmlRpc, "cloud.notify"); feed.Channel.Copyright = "Copyright 2007 Dallas Times-Herald"; feed.Channel.Generator = "Microsoft Spaces v1.1"; RssImage image = new RssImage(new Uri("http://dallas.example.com"), "Dallas Times-Herald", new Uri("http://dallas.example.com/masthead.gif")); image.Description = "Read the Dallas Times-Herald"; image.Height = 32; image.Width = 96; feed.Channel.Image = image; feed.Channel.Language = new CultureInfo("en-US"); feed.Channel.LastBuildDate = new DateTime(2007, 10, 14, 17, 17, 44); feed.Channel.ManagingEditor = "[email protected] (Jim Lehrer)"; feed.Channel.PublicationDate = new DateTime(2007, 10, 14, 5, 0, 0); feed.Channel.Rating = "(PICS-1.1 \"http://www.rsac.org/ratingsv01.html\" l by \"[email protected]\" on \"2007.01.29T10:09-0800\" r (n 0 s 0 v 0 l 0))"; feed.Channel.SkipDays.Add(DayOfWeek.Saturday); feed.Channel.SkipDays.Add(DayOfWeek.Sunday); feed.Channel.SkipHours.Add(0); feed.Channel.SkipHours.Add(1); feed.Channel.SkipHours.Add(2); feed.Channel.SkipHours.Add(22); feed.Channel.SkipHours.Add(23); feed.Channel.TextInput = new RssTextInput("What software are you using?", new Uri("http://www.cadenhead.org/textinput.php"), "query", "TextInput Inquiry"); feed.Channel.TimeToLive = 60; feed.Channel.Webmaster = "*****@*****.**"; #endregion }
/// <summary> /// Initializes the supplied <see cref="RssImage"/> using the specified <see cref="XPathNavigator"/> and <see cref="XmlNamespaceManager"/>. /// </summary> /// <param name="image">The <see cref="RssImage"/> to be filled.</param> /// <param name="navigator">The <see cref="XPathNavigator"/> used to navigate the image XML data.</param> /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> object used to configure the load operation.</param> /// <exception cref="ArgumentNullException">The <paramref name="image"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="navigator"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception> private static void FillImage(RssImage image, XPathNavigator navigator, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { Guard.ArgumentNotNull(image, "image"); Guard.ArgumentNotNull(navigator, "navigator"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); XPathNavigator linkNavigator = navigator.SelectSingleNode("link", manager); XPathNavigator titleNavigator = navigator.SelectSingleNode("title", manager); XPathNavigator urlNavigator = navigator.SelectSingleNode("url", manager); XPathNavigator descriptionNavigator = navigator.SelectSingleNode("description", manager); XPathNavigator heightNavigator = navigator.SelectSingleNode("height", manager); XPathNavigator widthNavigator = navigator.SelectSingleNode("width", manager); if (linkNavigator != null) { Uri link; if (Uri.TryCreate(linkNavigator.Value, UriKind.RelativeOrAbsolute, out link)) { image.Link = link; } } if (titleNavigator != null) { if (!String.IsNullOrEmpty(titleNavigator.Value)) { image.Title = titleNavigator.Value; } } if (urlNavigator != null) { Uri url; if (Uri.TryCreate(urlNavigator.Value, UriKind.RelativeOrAbsolute, out url)) { image.Url = url; } } if (descriptionNavigator != null) { image.Description = descriptionNavigator.Value; } if (heightNavigator != null) { int height; if (Int32.TryParse(heightNavigator.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out height)) { image.Height = height < RssImage.HeightMaximum ? height : RssImage.HeightMaximum; } } if (widthNavigator != null) { int width; if (Int32.TryParse(widthNavigator.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out width)) { image.Width = width < RssImage.WidthMaximum ? width : RssImage.WidthMaximum; } } SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(navigator, settings); adapter.Fill(image); }
//[ScriptMethod(ResponseFormat = ResponseFormat.Json)] public void CreateRSS() { ErrorLog.ErrorRoutine(false, "RSSCreated"); string strSQL = string.Empty; strSQL = @"Select TOP 5 e.iD, e.iUser, e.iCategory, e.iHtFt, e.iHtIn, e.txtBrand, e.txtDetails, e.txtOtherBoardType, e.txtGearItem, e.fltPrice, e.dCreateDate, e.txtImgPath1, tblUser.userDir FROM tblEntry e INNER JOIN tblUser ON e.iUser = tblUser.iD WHERE adtype = '1' AND iCategory = '1' ORDER BY e.dCreateDate DESC"; DataSet dsItems = new DataSet(); IDBManager dbManager = new DBManager(DataProvider.SqlServer); dbManager.ConnectionString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;; try { dbManager.Open(); dsItems = dbManager.ExecuteDataSet(CommandType.Text, strSQL); RssChannel channel = new RssChannel(); foreach (DataRow dr in dsItems.Tables[0].Rows) { RssItem item = new RssItem(); item.Title = dr["iHtFt"].ToString() + "' " + dr["iHtIn"].ToString() + "\" " + dr["txtBrand"].ToString() + ": " + Global.DecodeCategory(dr["iCategory"]); item.Link = new Uri("http://www.malzook.com/surfboard.aspx?iD=" + dr["iD"].ToString()); string strUrl = string.Empty; if (dr["txtImgPath1"] != DBNull.Value && dr["txtImgPath1"].ToString().Length > 1) { string strUserDir = Global.ReplaceEx(dr["userDir"].ToString(), @"\", @"/"); strUrl = "<img width=\"75\" height=\"75\" src=\"" + GetPicPath("thmbNail_" + dr["txtImgPath1"].ToString(), strUserDir) + "\"/>"; } item.Description = strUrl + Global.FormatDetails(dr["txtDetails"], (int)50); item.PubDate = Convert.ToDateTime(dr["dCreateDate"].ToString()); channel.Items.Add(item); } channel.Generator = "Boardhunt RSS Generator"; channel.Title = "Boardhunt: Used Surfboards for Sale"; channel.Description = "Boardhunt: Latest Boards"; channel.LastBuildDate = channel.Items.LatestPubDate(); channel.Link = new Uri("http://www.malzook.com/rss/surfboards.xml"); RssImage rssImg = new RssImage(); rssImg.Link = new Uri("http://www.malzook.com"); rssImg.Title = "Boardhunt logo"; rssImg.Height = 100; rssImg.Width = 160; rssImg.Url = new Uri("http://www.malzook.com/images/BHLogo.gif"); rssImg.Description = "Boardhunt is the online surfboard marketplace that allows searching and selling of used surfboards"; channel.Image = rssImg; RssFeed feed = new RssFeed(); feed.Channels.Add(channel); feed.Write(Server.MapPath(".\\..\\rss\\") + "surfboards.xml"); } catch (Exception ex) { ErrorLog.ErrorRoutine(false, "Admin:CreateRSS:" + ex.Message); } finally { dbManager.Close(); dbManager.Dispose(); } }
protected void CreateBlogRss() { string strSQL = string.Empty; string owner = System.Configuration.ConfigurationSettings.AppSettings["Owner"]; strSQL = @"SELECT TOP 5 " + owner + @".getBlogCommentCount(e.id) as COUNTER, e.id, e.blog_dt, e.title, e.cat, e.iUser, e.blog, e.txtImgPath1, e.txtImgPath2, e.iPageViewCount, u.userDir FROM tblBlog e INNER JOIN tblUser u on e.iUser = u.id WHERE e.publish ='Y' ORDER BY e.blog_dt DESC"; DataSet dsItems = new DataSet(); IDBManager dbManager = new DBManager(DataProvider.SqlServer); dbManager.ConnectionString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;; try { dbManager.Open(); dsItems = dbManager.ExecuteDataSet(CommandType.Text, strSQL); } catch (Exception ex) { ErrorLog.ErrorRoutine(false, "Admin:CreateRSS:" + ex.Message); } finally { dbManager.Close(); dbManager.Dispose(); } RssChannel channel = new RssChannel(); foreach (DataRow dr in dsItems.Tables[0].Rows) { RssItem item = new RssItem(); item.Title = dr["title"].ToString(); item.Link = new Uri("http://www.malzook.com/BlogDetails.aspx?iD=" + dr["iD"].ToString()); //TODO: add pics for blogs item.Description = Global.FormatDetails(dr["blog"], (int)50); item.PubDate = Convert.ToDateTime(dr["blog_dt"].ToString()); channel.Items.Add(item); } channel.Generator = "Boardhunt RSS Generator"; channel.Title = "Boardhunt: Surfing and Surfboard Blog"; channel.Description = "BH Latest Boards"; channel.LastBuildDate = channel.Items.LatestPubDate(); channel.Link = new Uri("http://www.malzook.com/rss/blog.xml"); RssImage rssImg = new RssImage(); rssImg.Link = new Uri("http://www.malzook.com"); rssImg.Title = "Boardhunt logo"; rssImg.Height = 100; rssImg.Width = 160; rssImg.Url = new Uri("http://www.malzook.com/images/BHLogo.gif"); rssImg.Description = "Boardhunt host a free service allowing the searching and selling of used surfboards"; channel.Image = rssImg; RssFeed feed = new RssFeed(); feed.Channels.Add(channel); feed.Write(Server.MapPath(".\\..\\rss\\") + "blog.xml"); }
/// <summary> /// Reads the next RssElement from the stream. /// </summary> /// <returns> An RSS Element </returns> /// <exception cref="InvalidOperationException">RssReader has been closed, and can not be read.</exception> /// <exception cref="System.IO.FileNotFoundException">RSS file not found.</exception> /// <exception cref="System.Xml.XmlException">Invalid XML syntax in RSS file.</exception> /// <exception cref="System.IO.EndOfStreamException">Unable to read an RssElement. Reached the end of the stream.</exception> public RssElement Read() { bool readData = false; RssElement rssElement = null; int lineNumber = -1; int linePosition = -1; if (this.reader == null) { throw new InvalidOperationException("RssReader has been closed, and can not be read."); } do { bool pushElement = true; try { readData = this.reader.Read(); } catch (EndOfStreamException e) { throw new EndOfStreamException("Unable to read an RssElement. Reached the end of the stream.", e); } catch (XmlException e) { if (lineNumber != -1 || linePosition != -1) { if (this.reader.LineNumber == lineNumber && this.reader.LinePosition == linePosition) { throw this.exceptions.LastException; } } lineNumber = this.reader.LineNumber; linePosition = this.reader.LinePosition; this.exceptions.Add(e); // just add to list of exceptions and continue :) } if (readData) { string readerName = this.reader.Name.ToLower(); switch (this.reader.NodeType) { case XmlNodeType.Element: { //if (reader.IsEmptyElement) // break; // doesnt take empty elements into account :/ this.elementText = new StringBuilder(); switch (readerName) { case "item": // is this the end of the channel element? (absence of </channel> before <item>) if (!this.wroteChannel) { this.wroteChannel = true; rssElement = this.channel; // return RssChannel readData = false; } this.item = new RssItem.RssItem(); // create new RssItem this.channel.Items.Add(this.item); break; case "source": this.source = new RssSource(); this.item.Source = this.source; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": try { this.source.Url = new Uri(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; } } break; case "enclosure": this.enclosure = new RssEnclosure(); this.item.Enclosure = this.enclosure; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": try { this.enclosure.Url = new Uri(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "length": try { this.enclosure.Length = int.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "type": this.enclosure.Type = this.reader.Value; break; } } break; case "guid": this.guid = new RssGuid(); this.item.Guid = this.guid; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "ispermalink": try { this.guid.PermaLink = bool.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; } } break; case "category": this.category = new RssCategory(); if ((string)this.xmlNodeStack.Peek() == "channel") { this.channel.Categories.Add(this.category); } else { this.item.Categories.Add(this.category); } for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": goto case "domain"; case "domain": this.category.Domain = this.reader.Value; break; } } break; case "channel": this.channel = new RssChannel.RssChannel(); this.textInput = null; this.image = null; this.cloud = null; this.source = null; this.enclosure = null; this.category = null; this.item = null; break; case "image": this.image = new RssImage(); this.channel.Image = this.image; break; case "textinput": this.textInput = new RssTextInput(); this.channel.TextInput = this.textInput; break; case "cloud": pushElement = false; this.cloud = new RssCloud(); this.channel.Cloud = this.cloud; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "domain": this.cloud.Domain = this.reader.Value; break; case "port": try { this.cloud.Port = ushort.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "path": this.cloud.Path = this.reader.Value; break; case "registerprocedure": this.cloud.RegisterProcedure = this.reader.Value; break; case "protocol": switch (this.reader.Value.ToLower()) { case "xml-rpc": this.cloud.Protocol = RssCloudProtocol.XmlRpc; break; case "soap": this.cloud.Protocol = RssCloudProtocol.Soap; break; case "http-post": this.cloud.Protocol = RssCloudProtocol.HttpPost; break; default: this.cloud.Protocol = RssCloudProtocol.Empty; break; } break; } } break; case "rss": for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); if (this.reader.Name.ToLower() == "version") { switch (this.reader.Value) { case "0.91": this.rssVersion = RssVersion.RSS091; break; case "0.92": this.rssVersion = RssVersion.RSS092; break; case "2.0": this.rssVersion = RssVersion.RSS20; break; default: this.rssVersion = RssVersion.NotSupported; break; } } } break; case "rdf": for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); if (this.reader.Name.ToLower() == "version") { switch (this.reader.Value) { case "0.90": this.rssVersion = RssVersion.RSS090; break; case "1.0": this.rssVersion = RssVersion.RSS10; break; default: this.rssVersion = RssVersion.NotSupported; break; } } } break; } if (pushElement) { this.xmlNodeStack.Push(readerName); } break; } case XmlNodeType.EndElement: { if (this.xmlNodeStack.Count == 1) { break; } string childElementName = (string)this.xmlNodeStack.Pop(); string parentElementName = (string)this.xmlNodeStack.Peek(); switch (childElementName) // current element { // item classes case "item": rssElement = this.item; readData = false; break; case "source": this.source.Name = this.elementText.ToString(); rssElement = this.source; readData = false; break; case "enclosure": rssElement = this.enclosure; readData = false; break; case "guid": this.guid.Name = this.elementText.ToString(); rssElement = this.guid; readData = false; break; case "category": // parent is either item or channel this.category.Name = this.elementText.ToString(); rssElement = this.category; readData = false; break; // channel classes case "channel": if (this.wroteChannel) { this.wroteChannel = false; } else { this.wroteChannel = true; rssElement = this.channel; readData = false; } break; case "textinput": rssElement = this.textInput; readData = false; break; case "image": rssElement = this.image; readData = false; break; case "cloud": rssElement = this.cloud; readData = false; break; } switch (parentElementName) // parent element { case "item": switch (childElementName) { case "title": this.item.Title = this.elementText.ToString(); break; case "link": this.item.Link = new Uri(this.elementText.ToString()); break; case "description": this.item.Description = this.elementText.ToString(); break; case "author": this.item.Author = this.elementText.ToString(); break; case "comments": this.item.Comments = this.elementText.ToString(); break; case "pubdate": try { this.item.PubDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { try { string tmp = this.elementText.ToString(); tmp = tmp.Substring(0, tmp.Length - 5); tmp += "GMT"; this.item.PubDate = DateTime.Parse(tmp); } catch { this.exceptions.Add(e); } } break; } break; case "channel": switch (childElementName) { case "title": this.channel.Title = this.elementText.ToString(); break; case "link": try { this.channel.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "description": this.channel.Description = this.elementText.ToString(); break; case "language": this.channel.Language = this.elementText.ToString(); break; case "copyright": this.channel.Copyright = this.elementText.ToString(); break; case "managingeditor": this.channel.ManagingEditor = this.elementText.ToString(); break; case "webmaster": this.channel.WebMaster = this.elementText.ToString(); break; case "rating": this.channel.Rating = this.elementText.ToString(); break; case "pubdate": try { this.channel.PubDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "lastbuilddate": try { this.channel.LastBuildDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "generator": this.channel.Generator = this.elementText.ToString(); break; case "docs": this.channel.Docs = this.elementText.ToString(); break; case "ttl": try { this.channel.TimeToLive = int.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "image": switch (childElementName) { case "url": try { this.image.Url = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "title": this.image.Title = this.elementText.ToString(); break; case "link": try { this.image.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "description": this.image.Description = this.elementText.ToString(); break; case "width": try { this.image.Width = Byte.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "height": try { this.image.Height = Byte.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "textinput": switch (childElementName) { case "title": this.textInput.Title = this.elementText.ToString(); break; case "description": this.textInput.Description = this.elementText.ToString(); break; case "name": this.textInput.Name = this.elementText.ToString(); break; case "link": try { this.textInput.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "skipdays": if (childElementName == "day") { switch (this.elementText.ToString().ToLower()) { case "monday": this.channel.SkipDays[0] = true; break; case "tuesday": this.channel.SkipDays[1] = true; break; case "wednesday": this.channel.SkipDays[2] = true; break; case "thursday": this.channel.SkipDays[3] = true; break; case "friday": this.channel.SkipDays[4] = true; break; case "saturday": this.channel.SkipDays[5] = true; break; case "sunday": this.channel.SkipDays[6] = true; break; } } break; case "skiphours": if (childElementName == "hour") { this.channel.SkipHours[Byte.Parse(this.elementText.ToString().ToLower())] = true; } break; } break; } case XmlNodeType.Text: this.elementText.Append(this.reader.Value); break; case XmlNodeType.CDATA: this.elementText.Append(this.reader.Value); break; } } } while (readData); return(rssElement); }