private static void ProcessItem(XmlNode node, List <FeedItem> items, DateTime dateContext, bool atom, RssChannelPriority priority) { XmlDocumentEx xmlDocument = (XmlDocumentEx)node.OwnerDocument; // Get the item title string itemTitle = null; if (atom) { itemTitle = node.SelectSingleNode("dfltns:title", xmlDocument.NamespaceManager).InnerText; } else { itemTitle = node.SelectSingleNode("title").InnerText; } // Get the item description string itemDescription = null; if (atom) { try { itemDescription = node.SelectSingleNode("dfltns:content[@type=\"html\"]", xmlDocument.NamespaceManager).InnerText; } catch { } if (itemDescription == null) { try { itemDescription = node.SelectSingleNode("dfltns:subtitle", xmlDocument.NamespaceManager).InnerText; } catch { } } } else { if (xmlDocument.NamespaceManager.HasNamespace("content")) { try { itemDescription = node.SelectSingleNode(".//content:encoded", xmlDocument.NamespaceManager).InnerText; } catch { } } if (itemDescription == null) { try { itemDescription = node.SelectSingleNode(".//description").InnerText; } catch { } } } // Get the item published date (if there is one) DateTime pubDate = dateContext; try { string pubDateString; if (atom) { pubDateString = node.SelectSingleNode("dfltns:published", xmlDocument.NamespaceManager).InnerText; } else { pubDateString = node.SelectSingleNode("pubDate").InnerText; } if (!String.IsNullOrEmpty(pubDateString)) { pubDate = Convert.ToDateTime(pubDateString); } } catch { } // Get the image width, height of the item XmlNodeList contentNodes = null; XmlNode content = null; string imageUrl = null; int width = -1, height = -1; if (atom) { content = node.SelectSingleNode(".//dfltns:link[@rel=\"enclosure\"][@type=\"image/jpeg\"]", xmlDocument.NamespaceManager); if (content != null) { imageUrl = content.Attributes["href"].Value; } } else { // See if there is a media tag if (xmlDocument.NamespaceManager.HasNamespace("media")) { contentNodes = node.SelectNodes(".//media:content[@type=\"image/jpeg\"]", xmlDocument.NamespaceManager); } // Try the enclosure variant if (contentNodes == null) { contentNodes = node.SelectNodes(".//enclosure[@type=\"image/jpeg\"]", xmlDocument.NamespaceManager); } if (contentNodes != null) { int maxFileSize = -1; foreach (XmlNode contentNode in contentNodes) { int fileSize = 0; try { fileSize = Convert.ToInt32(contentNode.Attributes["fileSize"].Value); } catch { } if (fileSize > maxFileSize) { content = contentNode; } } imageUrl = content.Attributes["url"].Value; if (!String.IsNullOrEmpty(imageUrl)) { try { string widthString = content.Attributes["width"].Value; if (!String.IsNullOrEmpty(widthString)) { width = Convert.ToInt32(widthString); } } catch { } try { string heightString = content.Attributes["height"].Value; if (!String.IsNullOrEmpty(heightString)) { height = Convert.ToInt32(heightString); } } catch { } } } } // Only save the data we need based on the priority if (priority == RssChannelPriority.Image && imageUrl != null) { itemTitle = null; itemDescription = null; } else if (priority == RssChannelPriority.Text && itemDescription != null) { imageUrl = null; width = -1; height = -1; } FeedItem feedItem = new FeedItem(); feedItem.title = itemTitle; feedItem.description = itemDescription; feedItem.pubDate = pubDate; feedItem.imageUrl = imageUrl; feedItem.imageWidth = width; feedItem.imageHeight = height; items.Add(feedItem); }