Thursday, May 23, 2019

XML To Java Object Conversion.

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

  1. Convert xml to XSD
  2. From XSD generate the java classes.
  3. Use JAXB library with marshalling and  unmarshalling mechanism.

Convert XML to XSD

  1. Go to following link http://xml.mherman.org/
  2. Copy your xml.
  3. Generate the XSD and download it.

Generate Java mapping classes 

  1. Navigate to folder where your xsd file is generated.
  2.  use the following command .This will generate all relevant java files.
    xjc  STEP-ProductInformation.xsd


No comments:

Post a Comment