Skip to main content

Jaxb marshalling more than one object

1 reply [Last post]
nffc_evans
Offline
Joined: 2010-04-28
Points: 0

Hi, I'm wondering how do I go about marshalling more than one object to XML? and conversely how best to unmarshal the resultant XML document? I'm quite dispondant at the moment, despite continuous effort I'm not getting anywhere.
I know I'm getting it wrong, I can do this with 1 object no problem, but how can I do it with more than one? Could I use a List? Array? I need all objects to be in one XML file so that rules out just using lots of XML files of course.
I would genuinely appreciate seeing a working example of the classic jaxb marshalling code with the small addition of marshalling multiple objects. I hope you understand, I've tried to word my question as cohesively as possible... thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nffc_evans
Offline
Joined: 2010-04-28
Points: 0

To continue, here is my marshal to xml code:

File outFile = new File("itemList2.xml"); 
try{
    FileOutputStream fout = new FileOutputStream(outFile);
    il. marshal(fout);
}finally {
    fout.close();
}