Пример #1
0
 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;
 }
Пример #2
0
 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;
 }