构建一个简单的RSS阅读器,检索内容 [英] Building a Simple RSS reader, retrieving content
问题描述
我试图让使用简单的RSS阅读器 SyndicationFeed
类
有一些标准的标记,如<标题>
,<链接>
,<描述>
...有没有与他们的问题。
但也有一些其他的标签。例如,这种饲料,该由WordPress创建的,所以<内容:编码>
标记。我想可能有其他网站的内容部分其他标记。对吧?
我想知道,如何找到每一个岗位的主要内容,有什么标准吗? ?哪些标记我应该寻找
(例如,一个网站可能使用<内容:编码>
,但其他一些只使用<描述>
或者有人用另一个标准......我不知道该怎么检索在主的内容做后)
PS:我使用这个代码来测试我的简单的RSS阅读器:
VAR读卡器= XmlReader.Create(http://feed.2barnamenevis.com/2barnamenevis);
VAR饲料= SyndicationFeed.Load(读卡器);
字符串s =;
的foreach(SyndicationItem我feed.Items)
{
S + = i.Title.Text +< BR />中+ i.Summary.Text +< BR />中+ i.PublishDate.ToString()+< BR />中;
的foreach(SyndicationElementExtension扩展在i.ElementExtensions)
{
的XElement ELE = extension.GetObject<&的XElement GT;();
S + = ele.Name +::+ ele.Value +< BR />中;
}
S + =<小时/>中;
}
返回小号;
我发现的 Argotic 的整合框架(感谢来自JoeEnos)。
Argotic有很多扩展,它可以是用于处理不属于标准元素。
例如,你可以使用 Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension
检索<内容:编码>
。你可以看到一个例子这里 。 (如果这个例子返回空
的内容,您只需要使用 MyRssItem.Description
)
一些其他有用的扩展是 WellFormedWebCommentsSyndicationExtension
(用于检索评论供稿网址)和 SiteSummarySlashSyndicationExtension
(检索意见计数)。
I am trying to make a simple RSS reader using SyndicationFeed
class.
There are some standard tags, like <title>
, <link>
, <description>
... there is no problem with them.
But there are some other tags. for example, in this feed, which created by WordPress, there is <content:encoded>
tag. I think there may be other tags for the content part of other websites. right?
I want to know, how to find the main content of every post, is there any standards? which tags should I look for?
(for example, a site may use <content:encoded>
but some other just use <description>
or someone use another standard... I don't know what to do for retrieving the main content of a post)
P.S : I'm using this code for testing my simple RSS reader:
var reader = XmlReader.Create("http://feed.2barnamenevis.com/2barnamenevis");
var feed = SyndicationFeed.Load(reader);
string s = "";
foreach (SyndicationItem i in feed.Items)
{
s += i.Title.Text + "<br />" + i.Summary.Text + "<br />" + i.PublishDate.ToString() + "<br />";
foreach (SyndicationElementExtension extension in i.ElementExtensions)
{
XElement ele = extension.GetObject<XElement>();
s += ele.Name + " :: " + ele.Value + "<br />";
}
s += "<hr />";
}
return s;
I have found Argotic Syndication Framework (thanks from JoeEnos).
Argotic has many Extensions, which can be used for handling elements which are not standard.
For example, You can use Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension
for retrieving <content:encoded>
. You can see an example here. (if that example returns null
for content, you should simply use MyRssItem.Description
)
Some other useful extensions are WellFormedWebCommentsSyndicationExtension
(for retrieving comments feed url) and SiteSummarySlashSyndicationExtension
(for retrieving comments count).
这篇关于构建一个简单的RSS阅读器,检索内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!