Skip to content

Instantly share code, notes, and snippets.

Created Sep 1, 2021
What would you like to do?
RSS + media thumbnail with XLinq and I don't know why
record Pan(string Style, decimal Price, string ProductUrl, string ThumbnailUrl)
public XElement ToRss(XNamespace mediaNs)
return new XElement("item",
new XElement("title", Style),
new XElement("description", $"Buy now for {Price}"),
new XElement("link", ProductUrl),
new XElement(mediaNs + "thumbnail", new XAttribute("url", ThumbnailUrl))
public class why
public void make_an_rss()
var pans = new List<Pan> { new Pan("Detroit", 30m, "", "") };
var mediaNs = XNamespace.Get("");
var doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("rss", new XAttribute("version", "2.0"), new XAttribute(XNamespace.Xmlns + "media", mediaNs),
new XElement("channel",
new XElement("title", "xt0rted's house of deals"),
new XElement("link", ""),
new XElement("description", "Bring the cheese if you please"),
new XElement("lastBuildDate", DateTimeOffset.UtcNow.ToString("O")),
pans.Select(pan => pan.ToRss(mediaNs))
var rss = doc.ToString(SaveOptions.None);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment