[jdom-interest] Creating multiple Elements

John L. Webber John.Webber at jentro.com
Mon Jan 12 02:56:59 PST 2004


Hello Moipone,

try something like this:

Element activityS = new Element("ActivitySummary");

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 activityT = new Element("Activity");

activityT.setText(new_activity[i]);

activityS.addContent(activityT);

}

}


XMLOutputter outputter = new XMLOutputter();

outputter.output(activityS, System.out);




Moipone Mocoancoeng wrote:

> 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 
> <http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus> 



-- 
---------------------------------------------------------
 Jentro Technologies GmbH
 John L. Webber, Software Development
---------------------------------------------------------
 Rosenheimer Str. 145e	    81671 München
 Tel. +49 89 189 169 80     mailto:John.Webber at jentro.com 
 Fax  +49 89 189 169 99     http://www.jentro.com
---------------------------------------------------------
NOTICE: The information contained in this e-mail is confidential or may otherwise be legally privileged. It is intended for the named recipient only. If you have received it in error, please notify us immediately by reply or by calling the telephone number above and delete this message and all its attachments without any use or further distribution of its contents. Please note that any unauthorised review, copying, disclosing or otherwise making use of the information is strictly prohibited. Thank you. 
---------------------------------------------------------





More information about the jdom-interest mailing list