471,305 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.



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

Dec 13 '06 #1
1 19895
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());

Dec 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by compu_global_hyper_mega_net_2 | last post: by
1 post views Thread by Mike Gifford | last post: by
reply views Thread by Börni | last post: by
3 posts views Thread by Mike | last post: by
12 posts views Thread by Stefan Weiss | last post: by
reply views Thread by Christoph Schneegans | last post: by
40 posts views Thread by VK | last post: by
reply views Thread by BG Mahesh | last post: by
reply views Thread by kempshall | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.