- public class MyXMLReader{
- public static void main(String args[]){
- try{
- long lasting =System.currentTimeMillis();
- File f=new File("data_10k.xml");
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(f);
- NodeList nl = doc.getElementsByTagName("VALUE");
- for (int i=0;i < nl.getLength();i++){
- System.out.println("车牌号码:" + doc.getElementsByTagName("NO").item(i)
- .getFirstChild().getNodeValue());
- System.out.println("车主地址:" + doc.getElementsByTagName("ADDR").item(i)
- .getFirstChild().getNodeValue());
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- System.out.println("运行时间:"+(System.currentTimeMillis() - lasting)+" 毫秒");
- }
- }
复制代码 在myeclipse里编辑器报Line25 syntax error,insert"}" to complete blok.可是不缺括号啊,怎么回事? |