I\'m using .NET\'s SyndicationFeed to create RSS and ATOM feeds. Unfortunately, I need HTML content in the description element (the Content property of the SyndicationItem)
I had the same problem as some where the WriteContentsTo override wasn't being called in cpowers example (still no idea why). So, I changed it to inherit from the SyndicationContent class instead. Not sure if this is the best solution, but worked great in my situation.
public class CDataSyndicationContent : SyndicationContent
{
public CDataSyndicationContent(string content)
{
Text = content;
}
public override SyndicationContent Clone()
{
return new CDataSyndicationContent(Text);
}
public override string Type
{
get { return "html"; }
}
public string Text { get; private set; }
protected override void WriteContentsTo(XmlWriter writer)
{
writer.WriteCData(Text);
}
}
try this
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = false;
//settings.ProhibitDtd = false;
using (XmlReader reader = XmlReader.Create(rssurl, settings))
try
item.Content = "<![CDATA[" +
SyndicationContent.CreateHtmlContent("<b>Item Content</b>") + "]]>";