gpt4 book ai didi

c# - 使用 SyndicationItem 类在 rss 提要中显示图像

转载 作者:行者123 更新时间:2023-12-02 17:22:46 25 4
gpt4 key购买 nike

我使用 System.ServiceModel.Syndication 创建 rss 提要

public ActionResult RSS()
{
List<C_Node> rssNodes = GetNodeList(takeNum: 20).ToList();
var syndItems = new List<SyndicationItem>();
foreach (var item in rssNodes)
{
var syndItem = new SyndicationItem()
{
Id = item.NodeId.ToString(),
Title = SyndicationContent.CreatePlaintextContent(String.Format("{0}", item.Title)),
Summary = SyndicationContent.CreateHtmlContent(HelperMethods.Truncate(item.Details, 400)),
Content = SyndicationContent.CreateHtmlContent(item.Details),
PublishDate = item.PostDate
};
//syndItem.ElementExtensions.Add("content:encoded", "", SyndicationContent.CreateHtmlContent(item.Details));
syndItem.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(ConfigurationManager.AppSettings["SiteUrl"] + Url.Action("Details", "Node", new { id = item.NodeId }))));//Nothing alternate about it. It is the MAIN link for the item.
syndItems.Add(syndItem);
}

return new RssFeed(title: Resources.Site.Title,
items: syndItems,
contentType: "application/rss+xml",
description: Resources.Site.Slogan);
}

我的问题是如何显示每个联合项目的图像?

最佳答案

完成添加此代码:

syndItem.ElementExtensions.Add(new XElement("image", item.ImageUrl));

关于c# - 使用 SyndicationItem 类在 rss 提要中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41430011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com