Prevent SyndicationClient showing HTML tags. RRS feed

  • Question

  • I want to get news from an rss feed of a news web site and show them in a textbox.. And here is the code I've tried..

    Uri feeduri = new Uri(@"http://lankacnews.com/sinhala/feed/");
                var feed = await client.RetrieveFeedAsync(feeduri);
                foreach (SyndicationItem item in feed.Items)
                    textBox1.Text += item.Title.Text + Environment.NewLine;
                    textBox1.Text += item.Summary.Text.ToString() + Environment.NewLine + Environment.NewLine;

    But the problem is it doesnt show only the title and news in the text box. It shows HTML tags such as <p> <br>..

     And some times it shows the whole HTML code for images like "<img class="alignnone size-full wp-image-109622" alt=anura-soami src="http://lankacnews.com/sinhala/wp-content/uploads/2014/02/anura-soami.png" width=630 height=753>"

    Is there anyway to prevent this ?

    Sunday, February 2, 2014 1:41 PM


All replies

  • Use a regular expression to strip them out of the string

    String result = Regex.Replace(htmlDocument, @"<[^>]*>", String.Empty);

    Sunday, February 2, 2014 3:54 PM
  • Isnt there anyway to do that with the syndication client ? 
    Monday, February 3, 2014 8:01 AM