Search in sources :

Example 1 with ParseErrorList

use of org.jsoup.parser.ParseErrorList in project jsoup by jhy.

the class Cleaner method isValidBodyHtml.

public boolean isValidBodyHtml(String bodyHtml) {
    Document clean = Document.createShell("");
    Document dirty = Document.createShell("");
    ParseErrorList errorList = ParseErrorList.tracking(1);
    List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList);
    dirty.body().insertChildren(0, nodes);
    int numDiscarded = copySafeNodes(dirty.body(), clean.body());
    return numDiscarded == 0 && errorList.size() == 0;
}
Also used : TextNode(org.jsoup.nodes.TextNode) Node(org.jsoup.nodes.Node) DataNode(org.jsoup.nodes.DataNode) ParseErrorList(org.jsoup.parser.ParseErrorList) Document(org.jsoup.nodes.Document)

Aggregations

DataNode (org.jsoup.nodes.DataNode)1 Document (org.jsoup.nodes.Document)1 Node (org.jsoup.nodes.Node)1 TextNode (org.jsoup.nodes.TextNode)1 ParseErrorList (org.jsoup.parser.ParseErrorList)1