简体   繁体   English

如何从rss文件中获取选定的项目?

[英]How to get selected items from the rss file?

Example code: 示例代码:

<rss version="2.0">
<channel>
  <item>
    <title>Title /title>
    <link>Link</link>
    <description>Desc</description>
  </item>
  <item>
    <title>Title</title>
    <link>Link</link>
    <description>Desc</description>   
  </item>
</channel>
</rss>

I get data from link: 我从链接获取数据:

XElement rss = XElement.Load("http://examplelink.com/file.rss");

and i want to save it but without any other elements, only title and link: 我想保存它,但没有其他任何元素,只有标题和链接:

rss.Save(@"C:\doc.txt");

How to do that? 怎么做?

You can use Syndication Feed class from System.ServiceModel.Syndication . 您可以使用System.ServiceModel.Syndication Syndication Feed类。

Take a look at this example 看这个例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM