Topic: Validating FEED Errors
I am using the following code from this page: https://itq.eu/knowledge/generating-rss-feed-asp-net-webpages/
@{ Layout = null; var ContentType = "application/rss+xml"; var sourceUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); // This is one of the things you have to do yourself ;-) var items = SomeSite.Net.Code.Blog.GetPosts(5); var feedItems = items.Select(p => new System.ServiceModel.Syndication.SyndicationItem(p.Title, p.Body, new Uri(string.Format("{0}/post/{1}", sourceUrl, p.Slug))) { PublishDate = new DateTimeOffset(p.CreateDate) }); var feed = new System.ServiceModel.Syndication.SyndicationFeed(feedItems) { Title = new System.ServiceModel.Syndication.TextSyndicationContent("SomeSite.Net", System.ServiceModel.Syndication.TextSyndicationContentKind.Html), Description = new System.ServiceModel.Syndication.TextSyndicationContent("A description of SomeSite.Net") }; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(this.Response.OutputStream)) { feed.GetRss20Formatter().WriteTo(writer); } this.Response.ContentType = ContentType; }
But when I validate the page I receive the following errors:
This feed does not validate.
-
column 4108: Missing channel element: link [help]
... Oct 2020 17:10:34 -0700 ^
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
-
column 39: Avoid Namespace Prefix: a10 [help]
help]
... ue, 06 Oct 2020 17:59:32 -0700help]
Author: DIVYA
PARTH
The solutions are as follows -
- and
1. add between
2. you cannot use a10
3. you have missed guid element in
4. add link with rel="self"
example - public SyndicationItem(string title, SyndicationContent content, Uri itemAlternateLink, string id, DateTimeOffset lastUpdatedTime);