您的位置:首页 > 其它

DOM4J 递归解析xml文件

2011-06-25 10:53 218 查看
public void read(Element e) {
if (e.nodeCount() > 0) {
Iterator<?> it = e.elementIterator();
while (it.hasNext()) {
Element ele = (Element) it.next();
read(ele);
System.out.println("Element :" + ele.getName() + " Path "
+ ele.getUniquePath());

if (ele.attributeCount() > 0) {
Iterator<?> ait = ele.attributeIterator();
System.out.print("  Data : [ ");
while (ait.hasNext()) {
Attribute attribute = (Attribute) ait.next();
System.out.print(attribute.getName() + " : "
+ attribute.getData() + "   ");
}
System.out.print(" ]");
System.out.println();
}
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: