C# string to Formatted HTML string

Is there a tool out there that can turn a C# string of unformatted HTML (no indentions, no new lines, etc) into a Formatted HTML string?
I am in a situation where I am generating an HTML string, and I am outputting it into a multiline textbox. Write now, it is wrapping, but is showing up similar to a paragraph. I would like it to be shown as formatted HTML? It wouldn’t even have to be very nice formatting, but at least not show a paragraph of HTML.
For having a good formatted HTML you can use this code:

try 
{
formattedOutput = System.Xml.Linq.XElement.Parse(myHtmlString).ToString();
}
catch { // isn't well-formed xml }

Leave a comment

Send a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.