Home > Back-end >  How can I get to the value in the analytic XML attributes to Java bean ah. As shown in figure, how t
How can I get to the value in the analytic XML attributes to Java bean ah. As shown in figure, how t

Time:10-04

How can I get to the value in the analytic XML attributes to Java bean, as shown in figure, how to design entity class?
<? The XML version="1.0" encoding="GBK"?>



CodePudding user response:

 File File=new File (sourcePath);//configuration path 

InputStream in=new FileInputStream (file);

SAXReader reader=new SAXReader ();
Document doc=reader. Read (in);
The Iterator elementIter=null, subelementIter=null;
Element Element=null, subelement=null;
String paramName="";
String paramValuehttps://bbs.csdn.net/topics/="";
int count=0;
//read the configuration file
ElementIter=doc. SelectNodes ("/p/d "). The iterator ();
While (elementIter. HasNext ()) {
Element=(element) elementIter. Next ();
ParamName=element. AttributeValue (" sname ");//in order to obtain the is Tom, dick and harry fifty
}



CodePudding user response:

Take out attributes to read and write in your entity class
  • Related