java代码org.xml.sax.SAXParseException中的HTML解析异常
我试图通过DOM解析器读取一个.html文件,但在解析时它给了我以下异常java代码org.xml.sax.SAXParseException中的HTML解析异常,java,dom,saxparser,Java,Dom,Saxparser,我试图通过DOM解析器读取一个.html文件,但在解析时它给了我以下异常 [Fatal Error] form3.html:559:133: The element type "font" must be terminated by the matching end-tag "</font>". org.xml.sax.SAXParseException; systemId: file:/home/puja/Dnyaneshwar/WCD_14_02_17/FileConverter
[Fatal Error] form3.html:559:133: The element type "font" must be terminated by the matching end-tag "</font>".
org.xml.sax.SAXParseException; systemId: file:/home/puja/Dnyaneshwar/WCD_14_02_17/FileConverter/resources/form3.html; lineNumber: 559; columnNumber: 133; The element type "font" must be terminated by the matching end-tag "</font>".
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
at DomConverter.main(DomConverter.java:25)
[Fatal Error]form3.html:559:133:元素类型“font”必须由匹配的结束标记“”终止。
org.xml.sax.SAXParseException;systemId:file:/home/puja/Dnyaneshwar/WCD_14_02_17/FileConverter/resources/form3.html;行号:559 ;;栏目号:133;元素类型“font”必须由匹配的结束标记“”终止。
位于com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
位于com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
位于javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
位于DomConverter.main(DomConverter.java:25)
您不需要使用XML解析器来解析HTML文档,甚至不需要使用xhtml文档
您可以使用像jsoup这样的html解析器。错误很明显,您有一个打开的
标记,而没有关闭的
尝试修复它。实际上,我已通过Libre office将文档文件转换为html。在这里,我通过手动编辑文件解决了许多类似上面的问题,但该文件太大了。那么我们可以禁用这种检查吗?