SyndicationFeed内容:编码 [英] SyndicationFeed content:encoded
本文介绍了SyndicationFeed内容:编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I&rsquo的,M使用 SyndicationFeed
类消耗一定的RSS源。我想知道如何获得内容:一个RSS feed的编码
节点。这是I&rsquo的代码,M使用:
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;
}
我可以使用 item.Summary的.text
但似乎返回说明
节点,它可以只是一个简短的总结,而内容:编码
将拥有的全部内容。有&rsquo的; S为 item.content
一种选择,但我不知道如何使用它和文档是稀缺的。
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.
推荐答案
试试这个:
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/>");
}
}
这篇关于SyndicationFeed内容:编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文