Use oxygen Gen to edit and generate xml files, and use java jaxb technology to complete xml parsing.
First, download the oxygen Gen XML Editor, which is a trial version (get trial licence after the software can be installed, and get the free 30-day permission, of course, we encourage everyone to use genuine software here !!!)
1. Create a blank XML file and click the following link:
5. Use the xjc command (provided by Java JDK !) Convert the. xsd file generated in the previous step to the. java file.
Open the cmd command line tool and switch to the directory where the. xsd file generated in the previous step is located;
Use the xjc command to complete the conversion: the complete. xsd file name to be converted by xjc-the complete target package name converted by p
Example: xjc AtmRadi_Param.xsd-p XMLBean. AtmRadi
The result is as follows:
Note: This step is replaced by a slightly simpler method: it is generated in step 5. after xsd, you can change it in advance. some data types in xsd to avoid many data types generated later. java files, but must be opened one by one. When changing the Data Type in. xsd, you can refer to the following table:
7 so far, you can use the JAXB technology provided by JDK + various. java files and. xml files formed above to parse the data in the xml file.
You can use the ready-made tool code: XMLToObj function in XmlUtil. java to convert an xml file to an object.
For specific application examples, see how to use the XMLUtilTest. java sample file.