Using Castor to Marshal a Java Class Properly

Discussion in 'Java' started by BuddahBelly, Feb 24, 2004.

  1. BuddahBelly

    BuddahBelly Guest

    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
    BuddahBelly, Feb 24, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Hwang
    Replies:
    0
    Views:
    622
    Sam Hwang
    Apr 26, 2005
  2. ado9868@___SSSPPPAAAMMM___katamail.com

    Castor Marshal Xsl

    ado9868@___SSSPPPAAAMMM___katamail.com, Mar 15, 2005, in forum: XML
    Replies:
    0
    Views:
    447
    ado9868@___SSSPPPAAAMMM___katamail.com
    Mar 15, 2005
  3. Pierre Rouleau
    Replies:
    2
    Views:
    276
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Nov 30, 2006
  4. Replies:
    10
    Views:
    530
    Aaron Watters
    Jun 18, 2008
  5. Michael Davis

    Ruby 1.8 and Marshal.load/Marshal.dump

    Michael Davis, Oct 10, 2003, in forum: Ruby
    Replies:
    0
    Views:
    167
    Michael Davis
    Oct 10, 2003
Loading...

Share This Page