I need to add new namespaces to the rss(root) element of my feed, in addition to a10:
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
<channel>
.
.
.
I am using a SyndicationFeed class serialized to RSS 2.0 and I use a XmlWriter to output the feed,
var feed = new SyndicationFeed(
feedDefinition.Title,
feedDefinition.Description,
.
.
.
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, settings))
{
rssFormatter.WriteTo(writer);
}
I have tried adding AttributeExtensions on SyndicationFeed but it adds the new namespaces to the channel element instead of the root,
Thank you
Unfortunately the formatter is not extensible in the way you need.
You can use an intermediate XmlDocument and modify it before writing to the final output.
This code will add a namespace to the root element of the final xml output: