zoukankan      html  css  js  c++  java
  • asp.net C# 简单RSS阅读器

    public void ProcessRSSItem(string rssURL)

            
    {
                 
    //使用一个字符串rssURL作为它的参数。这个字符串包含了RSS的URL。它使用rssURL的值建立了一个WebRequest项
                 System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssURL);

                 
    //请求的响应将会被放到一个WebResponse对象里
                 System.Net.WebResponse myResponse = myRequest.GetResponse();

                 
    //这个WebResponse对象被用来建立一个流来取出XML的值
                 System.IO.Stream rssStream = myResponse.GetResponseStream();

                 
    //使用一个XmlDocument对象来存储流中的XML内容。XmlDocument对象用来调入XML的内容
                 System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument();
                 rssDoc.Load(rssStream);

                 
    //个项应该在rss/channel/里。使用XPath表达,一个项节点列表可以如下方式创建
                 System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");

                 
    string title = "";
                 
    string link = "";
                 
    string description = "";

                 
    for (int i = 0; i < rssItems.Count; i++)
                 
    {

                  System.Xml.XmlNode rssDetail;

                  rssDetail 
    = rssItems.Item(i).SelectSingleNode("title");
                  
    if (rssDetail != null)
                  
    {
                   title 
    = rssDetail.InnerText;
                  }

                  
    else
                  
    {
                   title 
    = "";
                  }


                  rssDetail 
    = rssItems.Item(i).SelectSingleNode("link");
                  
    if (rssDetail != null)
                  
    {
                   link 
    = rssDetail.InnerText;
                  }

                  
    else
                  
    {
                   link 
    = "";
                  }


                  rssDetail 
    = rssItems.Item(i).SelectSingleNode("description");
                  
    if (rssDetail != null)
                  
    {
                   description 
    = rssDetail.InnerText;
                  }

                  
    else
                  
    {
                   description 
    = "";
                  }


                  Response.Write(
    "<p><b><a href='" + link + "' target='new'>" + title + "</a></b>" + description + "</p>");
                 
                 }


                }

                        
            
    //读取rss
            protected void btnRead_Click(object sender, EventArgs e)
            
    {
                
    string rssURL = txtUrl.Text.Trim();
                Literal1.Text 
    = "<font size=5><b>Site: " + rssURL + "</b></font><Br />";
                ProcessRSSItem(rssURL);
            }

    from: http://www.cnblogs.com/liudao/archive/2007/06/01/767672.html
  • 相关阅读:
    关于celery踩坑
    关于git的分批提交pull requests流程
    SymGAN—Exploiting Images for Video Recognition: Heterogeneous Feature Augmentation via Symmetric Adversarial Learning学习笔记
    AFN—Larger Norm More Transferable: An Adaptive Feature Norm Approach for Unsupervised Domain Adaptation学习笔记
    Learning to Transfer Examples for Partial Domain Adaptation学习笔记
    Partial Adversarial Domain Adaptation学习笔记
    Partial Transfer Learning with Selective Adversarial Networks学习笔记
    Importance Weighted Adversarial Nets for Partial Domain Adaptation学习笔记
    Exploiting Images for Video Recognition with Hierarchical Generative Adversarial Networks学习笔记
    improved open set domain adaptation with backpropagation 学习笔记
  • 原文地址:https://www.cnblogs.com/yiki/p/862013.html
Copyright © 2011-2022 走看看