public static FeedItem GetFromRssOrRdfItemNode(XmlNode node) { FeedItem fi = new FeedItem(); fi.hasBeenRead = false; foreach (XmlNode childNode in node.ChildNodes) { string innerText = childNode.InnerText; switch (childNode.Name.ToLower()) { case "title": fi.title = Feed.HtmlDecode(innerText); break; case "link": fi.linkUrl = innerText; break; case "category": fi.category = Feed.HtmlDecode(innerText); break; case "author": fi.author = Feed.HtmlDecode(innerText); break; case "pubdate": case "dc:date": fi.pubDate = fi.safeDateTimeParse(innerText); break; case "guid": //a linefeed in a guid causes problems with uniquely identifying items fi.guid = innerText.Replace("\r\n", ""); break; case "description": fi.description = innerText; break; case "content:encoded": fi.encodedContent = innerText; break; default: if (fi.unsupportedFeedItemProperties.ContainsKey(childNode.Name)) { fi.unsupportedFeedItemProperties[childNode.Name] += "|" + innerText; } else { fi.unsupportedFeedItemProperties.Add(childNode.Name, innerText); } break; } } fi.SetGuid(); fi.downloadDate = DateTime.Now; fi.setIncludedProperties(); return fi; }
private void setFeedSubNodeText(TreeNode node, FeedSubscription fs) { string text; bool errorCapturedAsItem = false; if (fs.Feed.ReadSuccess == false && fs.Feed.ReadException != null) { //text = fs.DisplayName + "(" + fs.Feed.ReadException.ToString() + ")"; FeedItem fi = new FeedItem(); fi.Author = "BetterReader"; fi.Description = string.Format("Error during read of feed: {0}", fs.Feed.ReadException); fi.DownloadDate = DateTime.Now; fi.HasBeenRead = false; fi.ParentFeed = fs.Feed; fi.PubDate = DateTime.Now; fi.Title = string.Format("Error reading feed: {0}", fs.Feed.ReadException.Message); fi.SetGuid(); fs.Feed.FeedItems.AddOrUpdate(fi); errorCapturedAsItem = true; } if (fs.Feed.ReadSuccess || errorCapturedAsItem) { text = fs.ToString(); if (fs.Feed.UnreadCount > 0) { node.NodeFont = feedsBoldFont; } else { node.NodeFont = feedsNormalFont; } if (fs.Feed.UnreadCount == 0 && hideReadFeedsBTN.Checked) { //user has selected hideReadFeeds option and this feed has no unread items feedsTreeView.HideNode(node); } else { feedsTreeView.ShowNode(fs); } } else { //if (fs.Feed.ReadException != null) //{ // //text = fs.DisplayName + "(" + fs.Feed.ReadException.ToString() + ")"; // FeedItem fi = new FeedItem(); // fi.Author = "BetterReader"; // fi.Description = string.Format("Error during read of feed: {0}", fs.Feed.ReadException); // fi.DownloadDate = DateTime.Now; // fi.HasBeenRead = false; // fi.ParentFeed = fs.Feed; // fi.PubDate = DateTime.Now; // fi.Title = string.Format("Error reading feed: {0}", fs.Feed.ReadException.Message); //} //else //{ text = "Loading . . ."; //} } node.Text = text; }
public static FeedItem GetFromAtomEntryNode(XmlNode node) { FeedItem fi = new FeedItem(); fi.hasBeenRead = false; foreach (XmlNode childNode in node.ChildNodes) { string innerText = childNode.InnerText; switch (childNode.Name.ToLower()) { case "title": fi.title = Feed.HtmlDecode(innerText); break; case "link": if (innerText != null && innerText != string.Empty) { fi.linkUrl = innerText; } else { fi.linkUrl = childNode.Attributes["href"].Value; } break; case "category": fi.category = Feed.HtmlDecode(innerText); break; case "author": foreach (XmlNode authorNode in childNode.ChildNodes) { if (authorNode.Name == "name") { fi.author = Feed.HtmlDecode(authorNode.InnerText); } } break; case "modified": fi.pubDate = fi.safeDateTimeParse(innerText); break; case "id": //a linefeed in the guid causes uniqueness problems fi.guid = innerText.Replace("\r\n", ""); break; case "content": fi.description = innerText; break; default: if (fi.unsupportedFeedItemProperties.ContainsKey(childNode.Name)) { fi.unsupportedFeedItemProperties[childNode.Name] += "|" + innerText; } else { fi.unsupportedFeedItemProperties.Add(childNode.Name, innerText); } break; } } fi.SetGuid(); fi.downloadDate = DateTime.Now; fi.setIncludedProperties(); return fi; }