DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); ClassPathResource resource = new ClassPathResource("reportType.xml"); ClassPathResource resource = new ClassPathResource("reportType。 Element root = doc.getDocumentElement(); NodeList list = root.getChildNodes(); for (int i = 0, len = list.getLength(); i
用你的程式碼試了下,沒出現錯誤,如果dom4j出錯,試試別的
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
}DocumentBuilder builder = factory.newDocumentBuilder();
ClassPathResource resource = new ClassPathResource("reportType.xml");
ClassPathResource resource = new ClassPathResource("reportType。 Element root = doc.getDocumentElement();
NodeList list = root.getChildNodes();
for (int i = 0, len = list.getLength(); i
我覺得是你xml檔案的問題,錯誤翻譯過來是:檔案提前結束! xml檔案可能沒有結尾標籤、開頭標籤錯誤等都可能遇到這種錯誤!你貼下你完整的xml檔
雷雷
編碼問題? xml檔屬性改為UTF-8試試看