I need help in constructing XML dynamically. I have a XSD associated with the XML. Thing is my xml contains repititive elements/block. Sometimes it might contain 3 elements or sometime only one. Sample xml is below
<?xml version="1.0" encoding="utf-8"?>
<addml>
<objectStore>
<folder>
<folderProperties>
<documentId>str1234</documentId>
<documentTitle>str1234</documentTitle>
<dateCreated>str1234</dateCreated>
</folderProperties>
<documents>
<document>
<docProperties>
<documentId>str1234</documentId>
<documentTitle>str1234</documentTitle>
<dateCreated>str1234</dateCreated>
</docProperties>
</document>
<document>
<docProperties>
<documentId>str1234</documentId>
<documentTitle>str1234</documentTitle>
<dateCreated>str1234</dateCreated>
</docProperties>
</document>
</documents>
</folder>
</objectStore>
</addml>
As you can see above document tag can appear many times. all the values I will be getting from variables like (String documentID = "1234"). I need help in how to loop the elements and construct the above xml in java. Any help is much appreciated.
Thanks, Mark