views:

460

answers:

3

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) and the formatter automatically encodes the HTML, but I'd rather have the entire description element wrapped in CDATA without encoding the HTML.

My (simple) code:

var feed = new SyndicationFeed("Title", "Description", 
               new Uri("http://someuri.com"));
var items = new List<SyndicationItem>();

var item = new SyndicationItem("Item Title", (string)null, 
               new Uri("http://someitemuri.com"));

item.Content = SyndicationContent.CreateHtmlContent("<b>Item Content</b>");

items.Add(item);
feed.Items = items;

Anybody an idea how I can do this using SyndicationFeed? My last resort is to "manually" create the XML for the feeds, but I'd rather use the built-in SyndicationFeed.

A: 

try

item.Content = "<![CDATA[" + 
            SyndicationContent.CreateHtmlContent("<b>Item Content</b>") + "]]>";
TheVillageIdiot
thx, but not working (compiler error), since item.Content requires an SyndicationContent object.The other way around is also not working, the content including the CDATA-tags is encoded:item.Content = SyndicationContent.CreateHtmlContent("<![CDATA[" + "<b>Item Content</b>" + "]]>)";
saxx
A: 

Did you ever find a solution to this? Having the exact same problem.

Paul
No, never figured it out. I ended up creating the XML myself (without syndication feed). Not a nice solution, but it works :|
saxx
+1  A: 

This should work.

item.Content =  new TextSyndicationContent("<b>Item Content</b>",TextSyndicationContentKind.Html);
Ross