⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 vs2005 c# 下的一个rss源解析类,采用解析较快的xmlreader,你完全可以用此类完成你自己的rss订阅器,只需要的是介面的开发了
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace test
{
    public partial class Form1 : Form
    {
        PtymRss.RssDataSource temp;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            temp = new PtymRss.RssDataSource();
            //temp.Url= Path.GetDirectoryName(Application.ExecutablePath)+@"\ddt.xml";
            temp.Url = textBox1.Text;
            temp.Load();
            //foreach (PtymRss.Rss_Channel x in temp.Rss.ChannelCollection)
            //{
            //    listBox1.Items.Add(x.Title);
            //}
            while (true)
            {
                if (temp.Isload)
                {
                    continue; 
                }
                else
                {   
                    foreach (PtymRss.Rss_Channel x in temp.Rss.ChannelCollection)
                    {
                        listBox1.Items.Add(x.Title);
                    }
                    break;
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void listBox1_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex > -1)
            {
                listBox2.Items.Clear();
                foreach (PtymRss.Rss_Item x in temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection)
                {
                    listBox2.Items.Add(x.Title);
                }
           

            label1.Text = "";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].Title + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].PubDate + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].WebMaster + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ManagingEditor+ "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].LastBuildDate + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].Language + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].Generator + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].Docs+ "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].Description + "\r\n";
            label1.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCount.ToString() + "\r\n";
 }

                    
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void listBox2_Click(object sender, EventArgs e)
        {
            if (listBox2.SelectedIndex > -1)
            {
                label2.Text = "";
                label2.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection[listBox2.SelectedIndex].Description + "\r\n";
                label2.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection[listBox2.SelectedIndex].Guid + "\r\n";
                label2.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection[listBox2.SelectedIndex].Link + "\r\n";
                label2.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection[listBox2.SelectedIndex].Pubdate+ "\r\n";
                label2.Text += temp.Rss.ChannelCollection[listBox1.SelectedIndex].ItemCollection[listBox2.SelectedIndex].Title + "\r\n";
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -