dom4j透过ElementIterator对xml节点进行遍历

dom4j通过ElementIterator对xml节点进行遍历xml文件:studentsstudentnamea/nameage19/agecou

dom4j通过ElementIterator对xml节点进行遍历
xml文件:

<students><student><name>a</name><age>19</age><course>math</cource><course>english</cource></student></students>



这里先获取student节点。

Element stu;

然后获取这个节点的子节点course的iterator对象
Iterator it=stu.elementIterator("course");while(itr.hasNext()){Element node=(Element) itr.next();                        System.out.println(node.getName());System.out.println(node.getText());}


这里便会输出:
course
math
course
english