|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Hello,
Does anybody here have any example code for Tidy.Net (http://sourceforge.net/projects/tidynet/) ? I can't find one single example. I try to convert a html-string to well formed xhtml, but the only output I get is /r/n Any help would be appreciated :) Best Regards Martin It wasn't actually that hard to figure it out ;) I just forgot to reset
the position of the stream, therefor the "/r/n"-result ;) Here is a code example if anyone else needs one in the future: Tidy tidy = new Tidy(); /* Set the options you want */ tidy.Options.DocType = DocType.Strict; tidy.Options.DropFontTags = true; tidy.Options.LogicalEmphasis = true; tidy.Options.Xhtml = true; tidy.Options.XmlOut = true; tidy.Options.MakeClean = true; tidy.Options.TidyMark = false; /* Declare the parameters that is needed */ TidyMessageCollection tmc = new TidyMessageCollection(); MemoryStream input = new MemoryStream(); MemoryStream output = new MemoryStream(); byte[] byteArray = Encoding.UTF8.GetBytes("Put your HTML here..."); input.Write(byteArray, 0 , byteArray.Length); input.Position = 0; tidy.Parse(input, output, tmc); string result = Encoding.UTF8.GetString(output.ToArray());
Other interesting topics
Search a file and find all occurences
Launch Application as Different User in C# Windows Applicatoin Visual Studio Plugin? Appropriate pattern KeyedCollection in use for GUI editor? Chicken in Egg problem... What is the best approach to deploy shared assemblies ? Outlook Message Format Library InvalidOperations excetion running wsh with Process class Setting up the Debugger. Windows service with a configuration file |
|||||||||||||||||||||||