{
DataSet dsArticles = new DataSet();
dsArticles.ReadXml(HttpContext.Current.Server.MapPath("Data.xml"));
DataView dvArticles = new DataView(dsArticles.Tables["article"]);
dvArticles.RowFilter =
"year = '" + year + "' " +
"and month = '" + month + "'";
Article currArticle = null;
IEnumerator articleRows = dvArticles.GetEnumerator();
while (articleRows.MoveNext())
{
DataRowView articleRow = (DataRowView)articleRows.Current;
currArticle = new Article(
(string)articleRow["year"],
(string)articleRow["month"],
(string)articleRow["title"],
(string)articleRow["content"]);
articles.Add(currArticle);
}
}
}
class Article
{
private string m_year;
public string Year
{
get { return m_year; }
set { m_year = value; }
}
private string m_month;
public string Month
{
get { return m_month; }
set { m_month = value; }
}
private string m_title;
public string Title
{
get { return m_title; }
set { m_title = value; }
}
private string m_content;
public string Content
{
get { return m_content; }
set { m_content = value; }
}
public Article(string year, string month, string title, string content)
{
Year = year;
Month = month;
Title = title;
Content = content;
}
}
public class Articles : List
{
public List
{
ArticleData dal = new ArticleData();
dal.GetArticles(this, year, month);
return this;
}
}
File: Data.xml