I am building an application that receives HTML content as strings. I need to verify that these HTML strings are well-formed, meaning I want to parse them and detect lines with errors.
During my research, I found that Jsoup might be a useful tool for this task. However, I am encountering issues getting it to work properly.
Parser parser = Parser.htmlParser().setTrackErrors(10);
Document document = Jsoup.parse("<div><-div>");
List<ParseError> errors = parser.getErrors();
Document document = Jsoup.parse("<div>/div>", "", htmlParser());
List<ParseError> errors = document().parser().getErrors();
Despite intentionally introducing errors in larger HTML strings, the getErrors() method always returns an empty list. Am I doing something wrong, or is Jsoup not suitable for this task? Additionally, if Jsoup isn’t the right tool, could someone recommend another library or method to achieve my goal?