我的問題很簡單: 有沒有辦法將java中的html解析爲DOM文檔,如果在htmlcontent中有像這樣的img-tag?在java中使用「未封閉標籤」解析html
<p><img src="..."></p>
這是Codesnippet,讓我的SAXException在解析這些元素:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = new ByteArrayInputStream(htmlcontent.getBytes());
Document dom = db.parse(is);
is.close();
工作非常適合我,謝謝! – billdoor 2012-07-12 14:53:52
隨時批准答案 – Florent 2012-07-12 15:03:13