using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;

namespace BookDemo.RSS
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            XDocument datasource = XDocument.Load("Datasource.xml");	//载入XML数据源
            //获取数据
            List<Article> articleList = datasource.Root.Elements("Article")	//获取根节点下的所有Article节点
               .OrderByDescending(a => Convert.ToInt32(a.Element("ID").Value))//按照ID降序排列
               .Select(a => new Article()										//输出Article类型
               {
                   ID = Convert.ToInt32(a.Element("ID").Value),					//ID
                   Title = a.Element("Title").Value,								//标题
                   Description = a.Element("Description").Value,	//描述
                   Text = a.Element("Text").Value,								//正文
                   CreateTime = Convert.ToDateTime(a.Element("CreateTime").Value)	//创建时间
               }).ToList();//转为List<Article>类型

            GridView1.DataSource = articleList;//将articleList作为GridView1的数据源
            GridView1.DataBind();//绑定数据到GridView1
        }

protected void btnSubmit_Click(object sender, EventArgs e)
{
    string rssUrl = txtRssUrl.Text.Trim();//获取URL地址
    Response.Redirect("FeedRss.ashx?url=" + Server.UrlEncode(rssUrl),true);//传递给FeedRss.ashx
}

    }

    class Article
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string Text { get; set; }
        public DateTime CreateTime { get; set; }
    }
}
