SyndicationFeed content:encoded

懵懂的女人 提交于 2019-11-30 14:04:20

问题


I’m using the SyndicationFeed class to consume some rss feeds. I am wondering how to get the content:encoded node of an RSS feed. This is the code I’m using:

XmlReader reader = XmlReader.Create(response.GetResponseStream());

SyndicationFeed feed = SyndicationFeed.Load(reader);

foreach (SyndicationItem item in feed.Items)
{
     string title = (item.Title != null) ? item.Title.Text : String.Empty;

     string content = ??

     string pubDate = (item.PublishDate != null) ? item.PublishDate.ToString("r") : String.Empty;

}

I can use item.Summary.Text but that seems to return the Description node, which can be just a short summary, while content:encoded will have the full content. There’s an option for item.content, but I'm not sure how to use it and documentation is scarce.


回答1:


Try this :

StringBuilder sb = new StringBuilder();
foreach (SyndicationElementExtension extension in item.ElementExtensions)
    {
         XElement ele = extension.GetObject<XElement>();
         if (ele.Name.LocalName == "encoded" && ele.Name.Namespace.ToString().Contains("content"))
         {
              sb.Append(ele.Value + "<br/>");
         }
    }


来源:https://stackoverflow.com/questions/1121565/syndicationfeed-contentencoded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!