Best method to parse various custom XML documents in Java

后端 未结 6 1027
死守一世寂寞
死守一世寂寞 2020-12-04 01:56

What is the best method to parse multiple, discrete, custom XML documents with Java?

6条回答
  •  青春惊慌失措
    2020-12-04 02:31

    Below is the code of extracting some value value using vtd-xml.

    import com.ximpleware.*;
    
    public class extractValue{
        public static void  main(String s[]) throws VTDException, IOException{
            VTDGen vg = new VTDGen();
            if (!vg.parseFile("input.xml", false));
            VTDNav vn = vg.getNav();
            AutoPilot ap = new AutoPilot(vn);
            ap.selectXPath("/aa/bb[name='k1']/value");
            int i=0;
            while ((i=ap.evalXPath())!=-1){
                System.out.println(" value ===>"+vn.toString(i));
            }   
        }
    }
    

提交回复
热议问题