如何打造RSS阅读器

                             电子科技大学软件学院03级02班 周银辉

关键点:下载RSS订阅所对应的XML文件,解析该XML文件

该类XML文件其形如:
如何打造RSS阅读器<?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
如何打造RSS阅读器 
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
如何打造RSS阅读器 
<channel>
如何打造RSS阅读器  
<title>博客园-this.Study(DateTime.Now)</title> 
如何打造RSS阅读器  
<link>http://www.cnblogs.com/zhouyinhui/</link> 
如何打造RSS阅读器  
<description>专业因为专注</description> 
如何打造RSS阅读器  
<language>zh-cn</language> 
如何打造RSS阅读器  
<lastBuildDate>Mon, 16 Oct 2006 05:33:31 GMT</lastBuildDate> 
如何打造RSS阅读器  
<pubDate>Mon, 16 Oct 2006 05:33:31 GMT</pubDate> 
如何打造RSS阅读器  
<ttl>60</ttl> 
如何打造RSS阅读器 
<item>
如何打造RSS阅读器  
<title>真正的代码宝库:Google Code Search</title> 
如何打造RSS阅读器  
<link>http://www.cnblogs.com/zhouyinhui/archive/2006/10/13/528421.html</link> 
如何打造RSS阅读器  
<dc:creator>周银辉</dc:creator> 
如何打造RSS阅读器  
<author>周银辉</author> 
如何打造RSS阅读器  
<pubDate>Fri, 13 Oct 2006 09:12:00 GMT</pubDate> 
如何打造RSS阅读器  
<guid>http://www.cnblogs.com/zhouyinhui/archive/2006/10/13/528421.html</guid> 
如何打造RSS阅读器  
<wfw:comment>http://www.cnblogs.com/zhouyinhui/comments/528421.html</wfw:comment> 
如何打造RSS阅读器  
<comments>http://www.cnblogs.com/zhouyinhui/archive/2006/10/13/528421.html#Feedback</comments> 
如何打造RSS阅读器  
<slash:comments>2</slash:comments> 
如何打造RSS阅读器  
<wfw:commentRss>http://www.cnblogs.com/zhouyinhui/comments/commentRss/528421.html</wfw:commentRss> 
如何打造RSS阅读器  
<trackback:ping>http://www.cnblogs.com/zhouyinhui/services/trackbacks/528421.html</trackback:ping> 
如何打造RSS阅读器 
<description>
如何打造RSS阅读器  
<![CDATA[ Google推出代码搜索&nbsp;,可以搜索到无数的开源代码,有让人欣喜若狂的感觉啊.<BR><BR>不用多说,快去看看 <A href="http://www.google.com/codesearch">http://www.google.com/codesearch</A><img src ="http://www.cnblogs.com/zhouyinhui/aggbug/528421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://zhouyinhui.cnblogs.com/" target="_blank">周银辉</a> 2006-10-13 17:12 <a href="/zhouyinhui/archive/2006/10/13/528421.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
如何打造RSS阅读器  
]]> 
如何打造RSS阅读器  
</description>
如何打造RSS阅读器 
</item>
如何打造RSS阅读器 
</channel>
如何打造RSS阅读器 
</rss>


如何下载

可以简单地利用 System.Net.WebClient 类,其对象有一个OpenRead(string url)方法,该方法可以打开一个Stream,可以使用该Stream来创建一个XmlDocument
如何打造RSS阅读器 WebClient client = new WebClient();
如何打造RSS阅读器 XmlDocument doc 
= null;
如何打造RSS阅读器
如何打造RSS阅读器            
try
            }


如何解析下载的XML文件:

注意到这样一个层次关系:一个RSS包含n个RssFeed,一个RssFeed包含n个RssChannel,RssChannel一个包含n个Item。这里的Item即一个项,它通常是一篇文章,包含标题、Url地址、简短描述等等.

RssItem:


RssChannel

 

RssFeed



---------------------------------------------------------------------

下载Demohttps://files.cnblogs.com/zhouyinhui/DemoForRss.rar

相关文章: