I'm reading an RSS feed via:
This works great, and I can see all the feed items in my DG. However, I want to limit the number of <items> (ie. to three rows) - and not use DG paging. I thought about just setting paging=true, set the # to 3 and hiding, through CSS, the paging field (display: none), but that's ugly.
So I figured I'd iterate through the reader, create a new XmlTextWriter, and omit any <item></item>'s who's count is > my max item count - ie. 3.
Can someone lend a hand on this one please, or recommend a better way to do this?
Thanks!
Code:
protected void Page_Load(object sender, EventArgs e)
{
recentPosts.DataSource = GetRSSFeed("[URL unfurl="true"]http://news.google.com/news?hl=en&ned=us&ie=UTF-8&q=Living+room+entertainment+furniture&output=rss");[/URL]
recentPosts.DataBind();
//Response.Write(GetRSSFeed("[URL unfurl="true"]http://www.aspmessageboard.com/scripts/rss.xml"));[/URL]
}
protected DataTable GetRSSFeed(string strURL)
{
// get the XML data
XmlTextReader reader = new XmlTextReader(strURL);
// return a new DataSet
DataSet ds = new DataSet();
ds.ReadXml(reader);
return ds.Tables[3];
}
This works great, and I can see all the feed items in my DG. However, I want to limit the number of <items> (ie. to three rows) - and not use DG paging. I thought about just setting paging=true, set the # to 3 and hiding, through CSS, the paging field (display: none), but that's ugly.
So I figured I'd iterate through the reader, create a new XmlTextWriter, and omit any <item></item>'s who's count is > my max item count - ie. 3.
Can someone lend a hand on this one please, or recommend a better way to do this?
Thanks!