Ravinder Godara
Ravinder Godara

Reputation: 57

Get indented html using tidyhtml in asp.net using c#

I'm trying to beautify html from string using tidyhtml5managed, code is:

using (Document doc = Document.FromString(myhtmltext)) //<html><head><...
            {
                doc.IndentAttributes = true;
                doc.CleanAndRepair();

                Literal1.Text = doc.ToString();
            }

I got output like this

TidyManaged.Document

My question is how to get html beautified output? Sorry for my bad English.

Upvotes: 0

Views: 329

Answers (1)

Oscar
Oscar

Reputation: 13960

What about reading the manual? Just call Save() instead of ToString()

using (Document doc = Document.FromString(dirtyHtml))
            {
                doc.OutputBodyOnly = AutoBool.Yes;
                doc.Quiet = true;
                doc.CleanAndRepair();
                string cleanHtml = doc.Save();

                Console.WriteLine("Clean HTML: " + cleanHtml);
            }

Upvotes: 1

Related Questions