Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
2.25/5 (3 votes)
See more:
can anybody please help me for

loading xml for blog feed from

"http://www.virtualeventshub.com/" url

or how to fetch blog feeds from url

for asp.net
Posted
Updated 26-Feb-14 0:55am
v2
Comments
[no name] 26-Feb-14 6:58am    
http://www.aspsnippets.com/Articles/Create-and-add-dynamic-RSS-Feed-from-Database-in-ASPNet-Website.aspx

relevant...
[no name] 26-Feb-14 7:02am    
http://www.virtualeventshub.com/feed/ use this url and make a webrequest, u shall receive feed in xml, later use the obtained xml and bind it to xmldatasource,later, link the datasource to datalist. or else there are plenty of jquery tools like news ticker and others, make use of them with jquery ajax get call to fetch feed from above url....

I have recently completed your kind of task.So I hope I can give you a maximum support.Please ask any question about this.

Here is the code snippets which I have used.


C#
/// <summary>
        /// to Get Blog Rss Feeds
        /// </summary>
        private List<RssReader> GetBlogRssFeeds(string rssUrl)
        {
            var rssFeed = XDocument.Load(rssUrl);

            var rssFeedOut = from item in rssFeed.Descendants("item")
                             select new RssReader
                             {
                                 Title = item.Element("title").Value,
                                 Link = item.Element("link").Value,
                                 Description = ((item.Element("description") != null) ? Regex.Replace(Regex.Replace(item.Element("description").Value, @"<[^>]+>|&nbsp;", "").Trim(), @"\s{2,}", " ") : "").Substring(0, 389),
                                 ImageSrc = (item.Element("description") != null) ? Regex.Match(item.Element("description").Value, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value : "",
                             };

            return rssFeedOut.ToList();
        }




C#
/// <summary>
    /// RssReader model
    /// </summary>
    public class RssReader
    {
        public string Link { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string ImageSrc { get; set; }
    }


HTML (MVC View)

XML
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<RssReader>>" %>
 <div id="divBlogContent">
                <table>

                    <% foreach (var p in Model)
                       { %>
                    <tr style="font-size: 18px; font-weight: bold; text-decoration: underline;">
                        <td colspan="2">
                            <%= Html.Encode(p.Title) %>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 400px; font-weight: normal; text-align: left">
                            <%= Html.Encode(p.Description) %>
                        </td>
                        <td style="width: 300px">
                            <img src="<%: p.ImageSrc %>" alt="Smiley face" height="120" width="200">
                        </td>
                    </tr>

                    <% } %>
                </table>
            </div>
 
Share this answer
 
v5
Comments
Member 9425683 26-Feb-14 11:54am    
can you please send me also code where you displayed data ,means html
Sampath Lokuge 27-Feb-14 1:36am    
I have updated my answer.Please check that.
thatraja 3-Mar-14 2:44am    
5!
Sampath Lokuge 3-Mar-14 2:46am    
Thanks Thatraja. :)
How to read and display RSS FEED in asp.net?

for Complete Source Code visit: http://dotnetawesome.blogspot.com/2013/11/how-to-read-and-display-rss-feed-in.html

private void PopulateRssFeed()
        {
            string RssFeedUrl = "http://timesofindia.feedsportal.com/c/33039/f/533965/index.rss";
            List<Feeds> feeds = new List<Feeds>();
            try
            {
                XDocument xDoc = new XDocument();
                xDoc = XDocument.Load(RssFeedUrl);
                var items = (from x in xDoc.Descendants("item")
                             select new
                             {
                                 title = x.Element("title").Value,
                                 link = x.Element("link").Value,
                                 pubDate = x.Element("pubDate").Value,
                                 description = x.Element("description").Value
                             });
                if (items != null)
                {
                    foreach (var i in items)
                    {
                        Feeds f = new Feeds 
                        { 
                         Title = i.title,
                         Link = i.link,
                         PublishDate = i.pubDate,
                         Description = i.description
                        };

                        feeds.Add(f);
                    }
                }

                gvRss.DataSource = feeds;
                gvRss.DataBind();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 
Share this answer
 
thanks i got result.this is working fine for me.
 
Share this answer
 

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