Question

I need below kind of out put after reading the rss feed from the blog feed.

enter image description here

I have written below code snippet for that.

private IEnumerable<RssReader> GetBlogRssFeeds()
        {

           var rssFeed = XDocument.Load("http://sampathloku.blogspot.com/feeds/posts/default?alt=rss");

             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.Match(item.Element("description").Value, @"^.{1,180}\b(?<!\s)").Value : ""
               };

        return rssFeedOut;
        }

View

<%@ Page Title="" ContentType="text/html" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<RssReader>>" %>

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <table border="1">

    <% foreach (var p in Model)
       { %>
    <tr border="1">
        <th>
            <%= Html.Encode(p.Title) %>
        </th>
    </tr>
    <tr border="1">
        <th>
            <%= Html.Encode(p.Description) %>
        </th>
    </tr>
    <tr border="1">
        <th>
            <%= Html.Encode(p.Link) %>
        </th>
    </tr>
    <% } %>
</table>
           </asp:Content>

But my Final out put shows everything is as below.

enter image description here

UPDATE

Now my View is as below.

enter image description here

My Question : How can I show Images and content are as above image ?

Updated Question : How can I get the description without html tags ?

Was it helpful?

Solution

Your content type is application/rss+xml. In that way it will never show up as html.

Just remove the ContentType="application/rss+xml" part or replace it with text/html and change your page to be html instead of rss.

There is no way to tell the browser: hey, you should read rss but format it like html. You can combine things (so rss tags in your html), but it will evaluate the way the browser thinks best (and that is not what you want).

Just output html from your rss reading and format it as html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top