Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] Creating multiple Elements

John L. Webber - Jentro AG

2004-01-12

Replies:

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@(protected)
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.
---------------------------------------------------------


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.