Learn As Much As You Can

Friday 8 November 2013

Get RSS Feed to your Website

Hi,
Today I have Implemented this simple method to get the RSS feed from any other website. Usually this is used to get the Daily/Breaking/Latest News to your website.
So, Now i am going to explain how we can achieve this via simple coding.

<marquee behavious="scroll" direction="up" scrollamount="4" onmouseover="this.stop()" onmouseout="this.start()"> 
    <div style=" text-justify: inter-word; text-align: justify">
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1" >
            <ItemTemplate>
                <a target="_blank" href='<%# XPath("link") %>'>
                    <%# System.Web.HttpUtility.HtmlEncode(XPath("title").ToString())%></a>
               <br />
             <asp:Label runat="server" ID="lbl_desc" Text='<%#XPath("description")%>' ></asp:Label>
              <%#XPath("pubDate") %>
                <br />
                <br />
            </ItemTemplate>
        </asp:Repeater>

    </div>
    </marquee>

 <asp:XmlDataSource ID="XmlDataSource1" runat="server" 
        DataFile="http://feeds.feedburner.com/breakingtravelnews/news" 

        XPath="rss/channel/item"></asp:XmlDataSource>


Explanation:
                   In XmlDataSource => DataFile => URL where you want to get the News
                                        XPath=> rss/channed/item => these are the nodes that defined in xml file for rss after that xml has "link" "description" "title" "pubDate" that i have used in repeater to get the Data.


Happy Coding :) :)



2 comments :