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");
            //获取数据
            List<Article> articleList = datasource.Root.Elements("Article")
                           .OrderByDescending(a => Convert.ToInt32(a.Element("ID").Value))
                           .Select(a => new Article()
                           {
                               ID = Convert.ToInt32(a.Element("ID").Value),
                               Title = a.Element("Title").Value,
                               Description = a.Element("Description").Value,
                               Text = a.Element("Text").Value,
                               CreateTime = Convert.ToDateTime(a.Element("CreateTime").Value)
                           }).ToList();

            GridView1.DataSource = articleList;
            GridView1.DataBind();
        }
    }
}
