2017-02-21 13 views
0

我想通過DOM解析器讀取一個.html文件,但它在解析時給我下面的異常。在java代碼中的HTML解析異常org.xml.sax.SAXParseException

[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) 
+1

錯誤很明顯你有一個打開的''標籤沒有關閉''試圖修復它 –

+0

其實,我通過Libre辦公室將doc文件轉換爲HTML。在這裏,我通過手動編輯文件解決了上述問題,但該文件非常大。那麼我們可以禁用這種檢查嗎? – Dnyanesh

回答

1

您不使用XML解析器來解析HTML文檔,甚至沒有解析xhtml文檔。

您可以使用像jsoup這樣的html解析器。