分类: Java
2007-06-13 19:41:06
package com.test; import java.io.*; import java.util.*; import org.jdom.*; import org.jdom.input.*; public class MyXMLReader { public static void main(String arge[]) { long lasting = System.currentTimeMillis(); try { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new File("data_10k.xml")); Element foo = doc.getRootElement(); List allChildren = foo.getChildren(); for(int i=0;i<allChildren.size();i++) { System.out.print("车牌号码:" + ((Element)allChildren.get(i)).getChild("NO").getText()); System.out.println(" 车主地址:" + ((Element)allChildren.get(i)).getChild("ADDR").getText()); } } catch (Exception e) { e.printStackTrace(); } System.out.println("运行时间:" + (System.currentTimeMillis() - lasting) + " 毫秒"); } } |