asp.net-mvc-3rsssyndication-item

SyndicationItem Content encoding


I am adding some simple tags to my SyndicationItem Content object like

var newSyndicationItem = new SyndicationItem(item.Title, item.Brief, new Uri("http://www.x.com/news/" + item.ID));
newSyndicationItem.PublishDate = new DateTimeOffset(item.PublishDate.Value);
newSyndicationItem.Content = SyndicationContent.CreateHtmlContent("<p style='direction:rtl' align='right' ><img src='http://x.sa.net/news/small/" + item.PicName + "' align='right' />" + item.Brief + "</p>");  

and rss output encodes the html tags, how can I fix this issue

<item>
      <link>http://www.x.com/news/details/3851</link>
      <title></title>
      <description>&lt;p style='direction:rtl' align='right' &gt;&lt;img src='http://x.sa.net/news/small/587_660.jpg' align='right' /&gt;قال أحمد خيري المتحدث الرسمي باسم حزب المصريين الأحرار في تصريح خاص لـ "الوطن"، أن سبب إصدار بيان الحزب اليوم، الذي يندد بالدعاية الدينية في المساجد&lt;/p&gt;</description>
      <pubDate>Mon, 14 May 2012 17:16:04 +0200</pubDate>
    </item>

please advice.


Solution

  • There's nothing to be fixed. That's valid XML and every decent XML parser will be able to read it correctly. If you do not properly encode the value of the description tag you will probably end up with invalid RSS.