0
Hi All我新的劍道mvc3和試圖讀取Stackoverflow Rss作爲我的網格模型,但我做不到。當我用雅虎的RSS我的項目工作,但不能與RSS#1工作
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; }
}
thanx ns工作 順便說一句,雅虎元素使用標題鏈接和項目標籤中的描述 – MustafaP