构建一个简单的RSS阅读器,检索内容

编程入门 行业动态 更新时间:2024-10-26 08:24:02
本文介绍了构建一个简单的RSS阅读器,检索内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图让使用简单的RSS阅读器 SyndicationFeed 类

有一些标准的标记,如<标题> ,<链接> ,<描述> ...有没有与他们的问题。

但也有一些其他的标签。例如,这种饲料,该由WordPress创建的,所以<内容:编码> 标记。我想可能有其他网站的内容部分其他标记。对吧?

我想知道,如何找到每一个岗位的主要内容,有什么标准吗? ?哪些标记我应该寻找

(例如,一个网站可能使用<内容:编码> ,但其他一些只使用<描述> 或者有人用另一个标准......我不知道该怎么检索在主的内容做后)

PS:我使用这个代码来测试我的简单的RSS阅读器:

VAR读卡器= XmlReader.Create(feed.2barnamenevis/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("feed.2barnamenevis/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阅读器,检索内容

本文发布于:2023-11-11 21:11:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阅读器   构建一个   简单   内容   RSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!