Hey,
I'm trying to create an XML Document from some HTML.
I am getting this exception:
[Fatal Error] :1:334: The element type "input" must be terminated by the matching end-tag "</input>".
Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException: The element type "input" must be terminated by the matching end-tag "</input>".
at server.XMLUtils.createDocument(XMLUtils.java:76)
The xml is like this:
<html>
<input name="s" size="5">
</html>
Is there some setting I can change in the parser to make it ignore missing closing tags?
Here is my current code
public static Document createDocument(InputStream is) {
try {
Document doc;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(is);
doc.getDocumentElement().normalize();
is.close();
return doc;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Thanks