Using Castor to Marshal a Java Class Properly

B

BuddahBelly

I am having problems Marshalling more then one class (of the same
type) at a time. Marshalling one class I can do. However when I want
to Marshal more then one instance i get this error in the XML
document: Only one top level element is allowed.

This is the code i am using:

//create a file to marshal to
FileWriter writer = null;
writer = new FileWriter( destDirectory + "test.xml" );

Marshaller mr = new Marshaller( writer );

//For each claim no get the model and print out the XML
for ( Iterator i = claimNos.iterator(); i.hasNext(); )
{
String claimNo = (String)i.next();
PensionInfo pensionInfoModel = PensionInfo.retrieve( claimNo
); //marshal the info
mr.marshal( pensionInfoModel );

}

Does anyone have any ideas on how to loop through more then one
instance and get it to Marshal properly?? Thanks for any help!!

EC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top