JAVA解析XML,SAXReader无法使用

2025-03-20 10:24:51
推荐回答(2个)
回答1:

try catch试试,我把你的程序简略的调试了下,没有问题:

import java.io.File;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

public class Aaa {
public static void main(String[] args) {
File file = new File("E:/home/xmltest/test.xml");
SAXReader reader = new SAXReader();
System.out.println("Dom4jxml2:555::SAXReader");
Document doc = null;
try {
doc = reader.read(file);
} catch (DocumentException e) {
e.printStackTrace();
}
System.out.println("Dom4jxml2:666::");
}
}

回答2:

看看你的错误信息