Java DOM 解析
SAX 解析参考:Java SAX 解析
# 无Validation
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new File(filename));
# DTD Validation
DocumentBuilderFactory.setValidating(true); DocumentBuilderFactory.setNamespaceAware(true);
# SAX ErrorHandler
DOM 解析支持 Sax ErrorHandler 错误通知
DocumentBuilder.setErrorHandler(ErrorHandler)