11

I want validate HTML code in Java.

Like this:

HTMLValidator.validateHTML("aaa<b>bbb<b>");
// Returns false, because tag <b> is not closed

What Java libraries exist to do this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Koerr
  • 15,215
  • 28
  • 78
  • 108
  • This question is closed and this one http://stackoverflow.com/questions/2144966/java-library-for-html-analysis is open - http://stackoverflow.com/questions/3152138/what-are-the-pros-and-cons-of-the-leading-java-html-parsers was of course closed but where is a current list of HTML Parser libraries for java now? – Wolfgang Fahl Sep 21 '14 at 14:41
  • http://stackoverflow.com/questions/3098114/how-to-validate-html-matches-w3c-standards is another question along these lines that is open. Since there is quite a bit of interest I'd like to edit this question to get it reopened. With 2000 reputation I can edit it but not do the reopen request. – Wolfgang Fahl Sep 22 '14 at 08:04

1 Answers1

21

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

http://jtidy.sourceforge.net/

Yada
  • 30,349
  • 24
  • 103
  • 144