Java Mailing List Archive

http://www.junlu.com/

Google Search
Google


Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Creating multiple Elements

Creating multiple Elements

2004-01-12       - By Moipone Mocoancoeng

 Back
Reply:     1     2  


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
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">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.</FONT></P
>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">Now
I need to create an XML doc using the values in the new_activity array with the
outcome like the following.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">&lt
;ActivitySummary&gt;</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </SPAN>&lt;Activity&gt; Training &lt;/Activity&gt;</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </SPAN>&lt;Activity&gt;Certification&lt;/Activity&gt;</FONT><
/P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">&lt
;/ActivitySummary&gt;</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman">
&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"
>Here?s my code</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"
>String actType = activity.getChild("Activity").getText();<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"
>String[] activity = <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>{"Training",
"RPL","Assessment", "Certification","CPD","EEP" };</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"
>String <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>new_activity[] = new String
[6];</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">for
(int i = 0; I &lt; activity.length; i++){</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>if(actType ==activity[i]){<
/FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </SPAN>if(actType!= new_activity[i]){</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; </SPAN>new_activity[i] = actType;</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </SPAN>}</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if(act[a]!=null){<o:p></o:p></FONT><
/P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Element activityS = new Element(
"ActivitySummary");<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Element activityT = new Element(
"Activity");<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>activityT.setText(new_activity[i]);
<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<
/SPAN>activityS.addContent(activityT);<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>XMLOutputter outputter = new
XMLOutputter();<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>outputter.output(activityS, System
.out);<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">
<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<SPAN style="mso-tab-count: 1">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">}<
/FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">The
result I get are as follows</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
>&lt;ActivitySummary&gt;</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </SPAN>&lt;Activity&gt; Training &lt;/Activity&gt;</EM></FONT
></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
>&lt;/ActivitySummary&gt;</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
>&lt;ActivitySummary&gt;</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab
-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Activity&gt
;Certification&lt;/Activity&gt;</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"><EM
>&lt;/ActivitySummary&gt;</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman">How
will I create this Activity element in a way that they?ll are multiple <SPAN
style="mso-spacerun: yes">&nbsp;</SPAN>element to the ActivitySummary element.<
/FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman"
>Best Regards</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman
">&nbsp;</FONT></o:p></P>
<P>&nbsp;</P><p><hr SIZE=1>
Do you Yahoo!?<br>
Yahoo! Hotjobs: <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs
/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus"
>Enter the "Signing Bonus" Sweepstakes</a>

Earn $52 per hosting referral at Lunarpages.
©2008 junlu.com - Jax Systems, LLC, U.S.A.