尤专门的xml文件操作的类,你直接查问党就可以哦了阿

解决方案 »

  1.   

    呵呵,在baidu一搜一大堆啊哥们
      

  2.   

    好多,比如jdom 就挺方便的
      

  3.   

    用了Apache提供的jdom类包
    import org.jdom.input.*;
    import org.jdom.*;
    import java.util.*;
    import java.io.*;
    public class  XMLExample2
    {
    public static void main(String[] args) 
    {    SAXBuilder sb = new SAXBuilder();
        try {
          Document doc = sb.build(new FileInputStream("text1.xml"));
          Element root = doc.getRootElement();
      System.out.println("节点名:"+root.getName());
      List lProperty = root.getAttributes();
    Iterator it = lProperty.iterator();
    while(it.hasNext())
    {
    System.err.println(" : "+root.getAttribute(((Attribute)it.next()).getName()).getValue());
    }
      List   ro = root.getChildren();
      Iterator it1 = ro.iterator();
      while(it1.hasNext())
    {
     Element el = (Element)it1.next();
     lProperty = el.getAttributes();
    Iterator it2 = lProperty.iterator();
    while(it2.hasNext())
    {
    System.err.println(" : "+el.getAttribute(((Attribute)it2.next()).getName()).getValue());
    }
    }
    }catch(Exception e)
    {
    e.printStackTrace();
    }
    }

    }
      

  4.   

    <?xml version="1.0" encoding="GBK"?>
    <VInfo ID='abc' Name='other'>
       <I User="KK" N="oo"/>
       <I User="KK" N="oo"/>
    </VInfo>