惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
Project Zero
Project Zero
D
DataBreaches.Net
I
InfoQ
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Vercel News
Vercel News
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
The Hacker News
The Hacker News
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Scott Helme
Scott Helme
T
Threatpost
爱范儿
爱范儿
N
Netflix TechBlog - Medium
D
Docker
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
K
Kaspersky official blog
H
Help Net Security
S
Secure Thoughts
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
G
Google Developers Blog
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
B
Blog
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
P
Privacy International News Feed
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog

博客园 - 北极熊,我来了!

C#获取类以及类下的方法(用于Asp.Net MVC) 使用JavaScript判断用户是否为手机设备 手机端页面自适应解决方案 Asp 邮件发送代码 js 日期字符串转换成日期类型,判断星期几 浅析a标签的4个伪类 《中文防止乱码的万能解决方案》 《小偷程序:自动获取百度天气预报》 Asp.NET使用HTML控件上传文件 《JS两级联动菜单学习全接触》 活动目录ADSI实现添加系统帐号问题!!! ADSI管理Windows2003系统帐号 中国频道空间使用Jmail发送邮件 《IP地址和数字之间转化的算法》 《单域名下整合动网、动易、OBlog程序》 JS读取XML数据 Asp.NET读取Excel数据 [XML系列]Flash读取XML数据 《省市联动功能菜单的实现》
C#读取Rss功能函数
北极熊,我来了! · 2009-06-13 · via 博客园 - 北极熊,我来了!

/// <summary>
/// 获取Rss资源
/// </summary>
/// <param name="RssURL"></param>
/// <returns></returns>
public static DataTable ReadRss(string RssURL)
{
    DataTable Dt = new DataTable();
    DataColumn Title = new DataColumn("Title", typeof(string));
    DataColumn Author = new DataColumn("Author", typeof(string));
    DataColumn PubDate = new DataColumn("PubDate", typeof(string));
    DataColumn Link = new DataColumn("Link", typeof(string));
    Dt.Columns.Add(Title);
    Dt.Columns.Add(Author);
    Dt.Columns.Add(PubDate);
    Dt.Columns.Add(Link);

    System.Net.WebRequest myRequest = System.Net.WebRequest.Create(RssURL);
    System.Net.WebResponse myResponse = myRequest.GetResponse();

    System.IO.Stream rssStream = myResponse.GetResponseStream();
    System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument();
    rssDoc.Load(rssStream);

    System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");
    for (int i = 0; i < rssItems.Count; i++)
    {
        DataRow Row = Dt.NewRow();
        System.Xml.XmlNode rssDetail;
        //标题
        rssDetail = rssItems.Item(i).SelectSingleNode("title");
        if (rssDetail != null)
        {
            Row["Title"] = rssDetail.InnerText;
        }
        else
        {
            Row["Title"] = "";
        }
        //作者
        rssDetail = rssItems.Item(i).SelectSingleNode("author");
        if (rssDetail != null)
        {
            Row["Author"] = rssDetail.InnerText;
        }
        else
        {
            Row["Author"] = "";
        }
        //发布时间
        rssDetail = rssItems.Item(i).SelectSingleNode("pubDate");
        if (rssDetail != null)
        {
            Row["PubDate"] = Convert.ToDateTime(rssDetail.InnerText).ToString("yyyy年MM月dd日");
        }
        else
        {
            Row["PubDate"] = "";
        }
        //链接地址
        rssDetail = rssItems.Item(i).SelectSingleNode("link");
        if (rssDetail != null)
        {
            Row["Link"] = rssDetail.InnerText;
        }
        else
        {
            Row["Link"] = "";
        }
        Dt.Rows.Add(Row);
    }
    return Dt;
}