使用dom4j遍历XML
public static void main(String[] args) throws DocumentException{
String path = XmlTest.class.getResource("/").getPath();
path = path.replace("%20", " ");
System.out.println(path);
File file = new File(path + "Students.xml");
SAXReader saxReader = new SAXReader();
Document document;
document = saxReader.read(file);
Element students=document.getRootElement();
for(Iterator i = students.elementIterator(); i.hasNext();){
Element student = (Element) i.next();
for(Iterator j = student.elementIterator(); j.hasNext();){
Element node=(Element) j.next();
System.out.println(node.getName()+":"+node.getText());
}}}