HTML Tidy in ASP.NET

  • Thread starter Christoph Schneegans
  • Start date
C

Christoph Schneegans

Hi!

I'd like to present an easy, yet powerful approach to use the HTML
Tidy program from <http://tidy.sourceforge.net/> in ASP.NET. It is
similiar to
<http://msdn.microsoft.com/library/d...vstechart/html/tchVSAddinEnablingHTMLTidy.asp>.
However, it is not implemented as a Visual Studio Add-in, but as a
response filter. This way, the complete HTML source is tidied,
including the output of web controls.

The VB.NET code can be downloaded from
<http://schneegans.de/temp/TidyFilter.vb.txt>. Furthermore, you need
the executable tidy.exe, which can be downloaded from
<http://tidy.int64.org/tidy-exe.zip>, and a configuration file
tidy.cfg. You should see reasonable results with
<http://schneegans.de/temp/tidy.cfg.txt>. Place both tidy.exe and
tidy.cfg in the root directory of your web application.

You call the filter by adding

Response.Filter = New TidyFilter(Response.Filter)

to your .aspx file(s). Page_Load seems to be the proper place to do
this.

Since Tidy is able to convert HTML to XHTML, you can use Tidy's output
to create an XmlDocument, by calling another filter:

Response.Filter = New TidyFilter(New XhtmlFilter(Response.Filter))

The XhtmlFilter class could apply an XSLT stylesheet to your page, add
arbitrary elements or attributes, or just change the attribute value
delimiter from " to '.

Feedback is greatly appreciated.
 
Joined
Jul 23, 2008
Messages
1
Reaction score
0
English Version Request.

Hi Cristoph,
I would really like to use your Tidy Filter in ASP.NET
The problem I have is that I do not understand Deutschen Sprach at all well enough to understand what is "going on" on the page. Could you provide me with an english alternative please?

Many thanks,
George Palframan.
 
Joined
Aug 8, 2006
Messages
2
Reaction score
0
Hello, I am trying to use this tidy library to remove spaces from my ASPX page output.

However, I am getting two errors.
- Invalid use of response filter.
- And I am having to assign execute permission.

Is this because my output is GZip compressed?

Please help.

Malay Thakershi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top