大家好我是 kendo mvc3 的新手,并试图将 Stackoverflow Rss 读作我的网格模型,但我做不到。当我使用 Yahoo RSS 时,我的项目工作但不能使用 Stackoverflow RSS
RSS 链接
https://stackoverflow.com/feeds http://news.yahoo.com/rss/
我的控制器功能
public static IEnumerable<Rss> GetRssFeed()
{
XDocument feedXml = XDocument.Load("https://stackoverflow.com/feeds");
var feeds = from feed in feedXml.Descendants("entry")
select new Rss
{
Title = feed.Element("title").Value,
Link = "<a href="+feed.Element("id").Value+">Go To Page</a>",
Description = feed.Element("summary").Value
};
return feeds;
}
public ActionResult Index()
{
var model = GetRssFeed();
return View(model);
}
****我的部分视图****
@model IEnumerable<KendoUIMvcApplication1.Models.Rss>
<div data-role="page" data-title="Aravind's Partial View Test" data-add-back-btn="true" data-back-btn-text="Back">
<div class="grid" style="margin-left: 5px;" id="grid">
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Pageable()
.Sortable()
.Scrollable()
.Columns(columns =>
{
columns.Bound(o => o.Title).Encoded(false);
columns.Bound(o => o.Description).Encoded(false);
columns.Bound(o => o.Link).Encoded(false);
})
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
)
)
</div>
</div>
**** 模型 ****
public class Rss
{
public string Link { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}