<div> <table cellpadding="0" cellspacing="0"> <tr> <td> <table class="NormalText" runat="server" id="tbl_Feed_Reader" cellpadding="0" cellspacing="0"> </table> </td> </tr> </table> </div>
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RSSFeedService rssFeedSerice_obj = new RSSFeedService(); ReadRssFeed(); } public void ReadRssFeed() { string rssFeedUrl = "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/cricket/rss.xml"; WebRequest requestFeedfrmUrl = WebRequest.Create(rssFeedUrl); WebResponse responseFeedfrmUrl = requestFeedfrmUrl.GetResponse(); Stream streamRssFedd = responseFeedfrmUrl.GetResponseStream(); XmlDocument scoreRssFeed = new XmlDocument(); scoreRssFeed.Load(streamRssFedd); XmlNodeList scoreNode = scoreRssFeed.SelectNodes("rss/channel/item"); string sTitle = ""; string sLink = ""; string sDescription = ""; //iterate through node list for (int i = 0; i < scoreNode.Count; i++) { XmlNode scoreRSSDetail; scoreRSSDetail = scoreNode.Item(i).SelectSingleNode("title"); if (scoreRSSDetail != null) { sTitle = scoreRSSDetail.InnerText; } else { sTitle = ""; } scoreRSSDetail = scoreNode.Item(i).SelectSingleNode("link"); if (scoreRSSDetail != null) { sLink = scoreRSSDetail.InnerText; } else { sLink = ""; } scoreRSSDetail = scoreNode.Item(i).SelectSingleNode("description"); if (scoreRSSDetail != null) { sDescription = scoreRSSDetail.InnerText; } else { sDescription = ""; } //generate HTML table HtmlTableCell block = new HtmlTableCell(); block.InnerHtml = "<span style='font-weight:bold'><a href='" + sLink + "' target='new'>" + sTitle + "</a></span>"; HtmlTableRow row = new HtmlTableRow(); row.Cells.Add(block); tbl_Feed_Reader.Rows.Add(row); HtmlTableCell block_description = new HtmlTableCell(); block_description.InnerHtml = "<p align='justify'>" + sDescription + "</p>"; HtmlTableRow row2 = new HtmlTableRow(); row2.Cells.Add(block_description); tbl_Feed_Reader.Rows.Add(row2); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)