Click here to Skip to main content
15,740,915 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to show live cricket score card on my web application. for achieving this i tried to read the RSS Feed from several site but its only showing me the match detail like time and the country between the game will be played.

Following is the code for aspx page
XML
<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>

in code behind :
C#
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);
            }
        }
    }

Can any one tell me whether this approach is right or help me with some suggestion.
Thanks
Posted
Updated 27-Feb-11 21:35pm
v2

html problem....how to solve?.........................
 
Share this answer
 
Reading an RSS feed is ok.
So basically on the whole this approach is ok.

Just wondering, why do you want to build an application like this when there are tons of them available anyway.
 
Share this answer
 
Comments
spydeehunk 28-Feb-11 3:49am    
I just want to create such kind of application, it for study purpose.if u hv any idea just let me now.Have you gone through this code because it not returnning live score. or M using not correct URL

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900