It's probablu because your RIch Text editor contains HTML, which makes the RSS generator throw up. So you should probably use something like this http://www.dotnetperls.com/remove-html-tags - Can't remember of there is a stripHtml function available though.
RichTextEditor data type throws error when writing RSS feed
I added posts from blog to RSS feed. Everything works fine. But I can't show summary of each post. I get the values of each post through below code,
IPublishedContent blog = Model.Content.AncestorOrSelf("SmBlog");
IEnumerable<IPublishedContent> posts = blog.Descendants("SmBlogPost").OrderBy("smBlogDate desc");
Then I write RSS feed as below,
Response.ContentType = "text/xml";
XmlTextWriter feedWriter = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
feedWriter.WriteStartDocument(); feedWriter.WriteStartElement("rss");
feedWriter.WriteAttributeString("version", "2.0");
feedWriter.WriteStartElement("channel");
feedWriter.WriteElementString("title", Model.Content.GetProperty("smBlogRssTitle").Value.ToString());
feedWriter.WriteElementString("description", Model.Content.GetProperty("smBlogRssDescription").Value.ToString());
feedWriter.WriteElementString("copyright", Model.Content.GetProperty("smBlogRssCopyright").Value.ToString());
feedWriter.WriteElementString("pubDate", postDate.ToString("ddd, dd MMMM yyyy HH:mm:ss"));
foreach (dynamic post in posts)
{
feedWriter.WriteStartElement("item");
feedWriter.WriteElementString("title", post.GetPropertyValue("smBlogTitle"));
feedWriter.WriteElementString("description",post.GetPropertyValue("smBlogSummary") );
feedWriter.WriteElementString("guid", Umbraco.NiceUrlWithDomain(post.Id));
feedWriter.WriteElementString("pubDate",
Convert.ToDateTime(post.GetPropertyValue("smBlogDate")).ToString("ddd, dd MMMM yyyy HH:mm:ss"));
feedWriter.WriteEndElement();
}
feedWriter.WriteEndElement(); feedWriter.WriteEndElement();
feedWriter.WriteEndDocument(); feedWriter.Flush();
feedWriter.Close(); Response.End();
post.GetPropertyValue("smBlogSummary") ); throws error as below,
When I change its data type to 'TextSring' from 'RichTextEditor', it works fine. But I need to display summary with 'RichTextEditor' data type.
Hi Thomas
It's probablu because your RIch Text editor contains HTML, which makes the RSS generator throw up. So you should probably use something like this http://www.dotnetperls.com/remove-html-tags - Can't remember of there is a stripHtml function available though.
/Jan
is working on a reply...