[jdom-interest] Creating multiple Elements

Moipone Mocoancoeng mmoipone at yahoo.com
Mon Jan 12 02:50:53 PST 2004


In my program I’m quiring the database for an activity then check the array of activities activity[6] if the activity exist in the array, if it does exist I then copy the activity into another array new_activity[6]. If the activity value already exist in the new_activity array I don’t copy the value.

Now I need to create an XML doc using the values in the new_activity array with the outcome like the following.

<ActivitySummary>

            <Activity> Training </Activity>

            <Activity>Certification</Activity>

</ActivitySummary>

 

Here’s my code

 

String actType = activity.getChild("Activity").getText();

String[] activity =  {"Training", "RPL","Assessment", "Certification","CPD","EEP" };

String  new_activity[] = new String[6];

for(int i = 0; I < activity.length; i++){

   if(actType ==activity[i]){

            if(actType!= new_activity[i]){

                        new_activity[i] = actType;

            }

     }

               if(act[a]!=null){

               Element activityS = new Element("ActivitySummary");

               Element activityT = new Element("Activity");

               activityT.setText(new_activity[i]);

               activityS.addContent(activityT);

               XMLOutputter outputter = new XMLOutputter();

               outputter.output(activityS, System.out);

               }                   

}

 

The result I get are as follows

<ActivitySummary>

            <Activity> Training </Activity>

</ActivitySummary>

<ActivitySummary>

            <Activity>Certification</Activity>

</ActivitySummary>

 

How will I create this Activity element in a way that they’ll are multiple  element to the ActivitySummary element.

 

Best Regards

 

 

 

 


---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20040112/fd9c36c2/attachment.htm


More information about the jdom-interest mailing list