I want to validate my HTML using JTidy. I want a response of true or false if it is valid or not, respectively. Currently I am using this code:
String htmlData = "<html><head></head><body><div>Hello Java </div></body></html>";
Tidy tidy = new Tidy();
InputStream stream = new ByteArrayInputStream(htmlData.getBytes());
tidy.parse(stream, System.out);
Is there a way to get a boolean response whether my HTML is valid or not?
According to the documentation you can get total error counts for your last parse operation using getParseErrors
So you can do something like