It seems like no matter what I do, I cannt get my twitter RSS feed to show up on my view. I'm not getting any errors, and the RSS feed loads correctly, I just can't grab the Model's information...
Here's my ViewModel
namespace MvcMusicStore.ViewModels
{
public class HomeRssFeedViewModel
{
public IEnumerable<TwitterPosts> Tweets { get; set; }
public HomeRssFeedViewModel()
{
Tweets = GetPosts();
}
public IEnumerable<TwitterPosts> GetPosts()
{
var xmlTreeTwitter = XDocument.Load("http://twitter.com/statuses/user_timeline/...");
XNamespace xmlns = "http://www.w3.org/2005/Atom";
return from item in xmlTreeTwitter.Descendants(xmlns + "item")
select new TwitterPosts
{
pubDate = item.Element(xmlns + "pubDate").Value,
Title = item.Element(xmlns + "Title").Value,
Link = item.Element(xmlns + "link").Value
};
}
public class TwitterPosts
{
public string pubDate { get; set; }
public string Title { get; set; }
public string Link { get; set; }
}
}
}
Here's my Controller:
public ActionResult Index()
{
var viewModel = new HomeRssFeedViewModel();
return View(viewModel);
}
Here's my View:
%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcMusicStore.ViewModels.HomeRssFeedViewModel>" %>
...
<div class="rss">
<% foreach(var tweet in Model.Tweets)
{%>
<b><%: tweet.Title %></b>
<% } %>
</div>