generate xml from java and sql query

magsinfin

New Member
I am using the following query:\[code\]SELECT inst.*FROM (SELECT ROWNUM AS r, b.name INSTNAME, ICC.INSTITUTE_ID, ICC.COURSE_ID, c.name INSTCOURSE FROM INSTITUTE_COURSE_CATEGORY ICC, INSTITUTE a, MEMBER b, INSTITUTE_COURSE c WHERE ICC.CATEGORY_ID = 47 AND ICC.INSTITUTE_ID = a.id AND ICC.INSTITUTE_ID = c.institute_id AND ICC.COURSE_ID = c.id AND a.member_id = b.id )instWHERE inst.r BETWEEN 1 AND 10\[/code\]to produce following result:\[code\] R INSTNAME INSTITUTE_ID COURSE_ID INSTCOURSE 1 Asia Pacific Institute Of Mangement 167 1134 Post Graduate Diploma in Management 2 Asia Pacific Institute Of Mangement 167 1135 Post Graduate Diploma in Management (Marketing) 3 Asia Pacific Institute Of Mangement 167 1136 Post Graduate Diploma in Management (International Business) 4 Asia Pacific Institute Of Mangement 167 1138 Post Graduate Diploma in Management (Banking & Financial Services) 5 University of Delhi 182 4283 Bachelor of Business Studies 6 University of Delhi 182 4285 Bachelor of Commerce (Pass) 7 University of Delhi 182 4291 Bachelor of Commerce (Honours) 8 University of Delhi 182 4366 Master of Commerce 9 Acharya Narendra Dev College 183 812 B.Com. (Hons) 10 Aditi Mahavidyalaya 184 829 B.Com (Pass) \[/code\]From the above query result, I had to make the following xml in java:\[code\]<Root> <INSTITUTE> <ID>167</ID> <NAME>Asia Pacific Instiute Of Mangement</Name> <COURSES> <COURSE> <ID>1134</ID> <NAME>Post Graduate Diploma in Management</NAME> </COURSE> ..more </COURSES> </INSTITUTE> ..more</Root>\[/code\]For Example:\[code\]There are 4 Courses that belongs to InstituteID(167). The problem I am facing is how to make 4 child nodes (Courses Nodes(1134,1135,1136,1138)) under a single `<INSTITUTE>` node\[/code\]and subsequently make other courses node under their respective\[code\]<INSITUTE>\[/code\]nodes.Kindly provide suggestion...
 
Back
Top