Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any java libraries for validating user supplied HTML, on the server side?

I have a service which takes the user supplied rich text (can have HTML tags) and saves it into the database. That data gets used by some other application. But sometimes the user supplied data has missing HTML tags and wrong closing tags. I want to validate if the user supplied data is valid HTML or not and depending on that I want to warn the user.

Are there any java libraries to do HTML validation?

like image 705
chetu Avatar asked Feb 25 '10 17:02

chetu


2 Answers

You can try JTidy, but it's too slow for simple HTML cleaning.

If you want just process HTML you can try NekoHTML, it's lightweight and fast

like image 121
Igor Artamonov Avatar answered Oct 18 '22 23:10

Igor Artamonov


You can try JTidy.

JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer.

like image 3
Desintegr Avatar answered Oct 19 '22 00:10

Desintegr