-2

http://api.gamebanana.com/Core/Item/Data?itemtype=Blog&itemid=18235&fields=text

My goal is to grab the text from this webpage and put it into a string with the linebreaks that are defined in the HTML. This text will then be put into a textbox for displaying on the form. My current issue is that I cannot convert the text into a string that has the line breaks like in the HTML. I am using HTMLAgilityPack with C#. What would be the best way to go about this?

Note: Preferably, I can ignore the list item (li) formatting.

Current string result: Couple of updates today:Refactored Events and Meetings, they now share similar logic. Events now have duration and repeat type.Added upcoming events to BananaAds.Re-added persistent header.Modboy improvements.Added award vote broadcasting.Replaced todolist icons rather than labels.More tomorrow!

  • seems to me you just want to strip all HTML tags, right? – Leonel Atencio Oct 01 '16 at 01:51
  • Please provide [MCVE] and expected result. So far question reads as "implement some code to my liking" which is not good fit for SO. If you just want to advertise link to random site - this could be considered spam (which may be your goal too). – Alexei Levenkov Oct 01 '16 at 01:54
  • I am not trying to spam. I am simply trying to understand how to convert an HTML to a multiline string. – Megamooman Oct 01 '16 at 02:01

1 Answers1

0

Ok, so i other words, you just need to strip the string from HTML tags. Please refer to this other SO question, where they give examples on this. Also, on this other, they do it with Regex. (Might be simpler and shorter).

public static string StripHTML(string input)
{
   return Regex.Replace(input, "<.*?>", String.Empty);
}
Community
  • 1
  • 1
Leonel Atencio
  • 474
  • 3
  • 14
  • OP already uses HtmlAgilityPack - please justify clearly inferior approach you are recommending. (in addition to reason of posting essentially duplicate answer instead of flagging for duplicate) – Alexei Levenkov Oct 01 '16 at 01:55
  • @AlexeiLevenkov Does HtmlAgilityPack have means to strip off HTML tags? – Abion47 Oct 01 '16 at 01:59
  • @LeonelAtencio If there's an in-library solution, why not post that? – Abion47 Oct 01 '16 at 04:15