Conversion of complex xml to java
In this blog I will explain how you can convert a complex xml in to java object.This will be very use full when you are validating xml values.
Mechanism
- Convert xml to XSD
- From XSD generate the java classes.
- Use JAXB library with marshalling and unmarshalling mechanism.
Convert XML to XSD
- Go to following link http://xml.mherman.org/
- Copy your xml.
- Generate the XSD and download it.
Generate Java mapping classes
- Navigate to folder where your xsd file is generated.
- use the following command .This will generate all relevant java files.
xjc STEP-ProductInformation.xsd