Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output a generated HTML string to a textbox without paragraph formating [closed]

Tags:

c#

wpf

I am generating an HTML string in a WPF application, and I am outputting it to a multiline textbox. Right now the output 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.

How can I accomplish this?

like image 492
TheJediCowboy Avatar asked Apr 15 '11 17:04

TheJediCowboy


1 Answers

If your HTML is well-formed XML, then the XElement.ToString() method will format with indents and newlines:

try
{
    formattedOutput = System.Xml.Linq.XElement.Parse(myHtmlString).ToString();
}
catch
{
    // isn't well-formed xml
}
like image 55
Ed Power Avatar answered Oct 06 '22 00:10

Ed Power