How to generate XML from an XML schema in Java and feed the data in it?

I am developing a part of a web application that uses an XML schema as input to create an XML file. There is also data for orderly placement in XML tags.

For example, if I have an ArrayList with 100 numbers, say, from 1 to 100, it .xsdlooks like this:

xs:element name="elt1"

xs:complexType

xs:sequence

  xs:element name="elt1-1"

  xs:element name="elt1-2"

  xs:element name="elt1-3"

  xs:element name="elt1-4"

  xs:element name="elt1-5"

xs:sequence

xs:complexType

xs:element name="elt1" 

......other elements

How can I generate an XML file as shown below:

< elt1>

   < elt1-1>1< elt1-1>

   < elt1-2>2< elt1-2>

   < elt1-2>3< elt1-3>

   < elt1-4>4< elt1-4>

   < elt1-5>3< elt1-5>

< elt1>

So the data in each tag is the corresponding number in the array, in the same order as the data in the array?

I would really appreciate any suggestion or example. Thanks in advance!

+7
source share

All Articles