Parsing html string to dom document using cyberneko

1k Views Asked by At

I'm trying to parse a html string to a w3c dom document using neko html but my document is always null. This I the code is use:

try {
        String html = readFile("C:/Users/thomas/Desktop/test.html");

        InputStream is = new ByteArrayInputStream(html.getBytes("UTF-8"));

        DOMParser parser = new DOMParser();

        parser.parse(new InputSource(is));
        Document document = parser.getDocument();

        System.out.println(parser.getDocumentSource());
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
0

There are 0 best solutions below