First download Oxygen software (Oxygen XML Editor), currently using a trial version (you can install the software after get trial licence, get free to use 30 days of permission, of course, we encourage you to use genuine software!!! )
1 First create a blank XML file, directly click on the following:
2 You can use the XML text editing interface, or use the XML tree diagram to edit the interface
To switch to the XML tree diagram, edit the interface in the following ways:
You can bring up the XML tree graph editing interface corresponding to the current XML file.
3 Designing and editing XML files
You can easily design your own XML document format using the XML tree diagram operator interface according to your needs.
4 Use the conversion function provided by the oxygen software itself to generate the corresponding. xsd file for the. xml file, as follows:
The. xsd file that corresponds to the. xml file is generated below the corresponding folder:
5 Using the XJC command (Java's JDK is available!) Convert the. xsd file generated in the previous step to a. java file
Open the CMD command-line tool and switch to the directory where the. xsd file was generated in the previous step.
Complete the conversion with the XJC command:XJC the full destination package name of the. xsd full file name –p conversion to convert.
Example: XJC atmradi_param.xsd–p Xmlbean.atmradi
The resulting results are as follows:
A lot of. java files have been generated in the Xmlbean folder at this time
6 Change the type of the variable in the. java file that was generated in the previous step. Typically, the data types BigInteger, BigDecimal, and so on are changed to normal int, double type
Note: This step has a slightly simpler way to replace it: after you build the. xsd in step ⑤, you can change the. XSD data types directly in advance, so that you avoid generating many. java files later, but you need one to open to change. You can refer to the following table when you change the data type in the. xsd:
7 by this end, you can use the JAXB technology provided by the JDK + the various. java files +. xml files formed above to complete the parsing of the data in the XML file
Here you can use the ready-made tool code: The Xmltoobj function in Xmlutil.java to transform from an XML file to an object.
Examples of specific applications can be found in: xmlutiltest.java example files are given using the method.
Use oxygen to edit and generate XML files, and use Java's JAXB technology to parse XML