[jdom-interest] Only getting the first element node

David Parker dlparker at facstaff.wisc.edu
Mon Oct 9 16:27:56 PDT 2000


I'm not sure why but I'm only getting the first course.
It is only going through the while loop once.
Can anyone tell me why?
-------------------------------------------------------------------------------------------------------------------------------------
try {
         // Request document building without validation
         org.jdom.input.DOMBuilder builder = new 
org.jdom.input.DOMBuilder(false);
         org.jdom.Document jdomDoc = builder.build(doc);

         // Get the root element
         org.jdom.Element root = jdomDoc.getRootElement();

         List mycourse = root.getChildren();             //return all children
         java.util.Iterator iter = mycourse.iterator();

         //Returns true if the iteration has more 
elements. 

         while (iter.hasNext()) {

                 org.jdom.Element term = (org.jdom.Element) iter.next();

                 courseDescription = 
term.getChild("class").getChild("course").getChild("description").getContent();
                 courseSubject = 
term.getChild("class").getChild("course").getChild("subject").getContent();
                 courseCatalognumber = 
term.getChild("class").getChild("course").getChild("catalognumber").getContent();
                 courseUnits = 
term.getChild("class").getChild("course").getChild("units").getContent();
                 courseSection = 
term.getChild("class").getChild("course").getChild("section").getContent();
                 courseComponent = 
term.getChild("class").getChild("course").getChild("component").getContent();
                 courseSessioncode = 
term.getChild("class").getChild("course").getChild("sessioncode").getContent(); 


         }

  } catch (Exception e) {
         usrErrMsg += "org.jdom.???  <br>";
         e.printStackTrace();
}

Sincerely,
David Parker

mailto:david.parker at doit.wisc.edu

Library, Instructional & Retrieval Applications,
DoIT - University of Wisconsin-Madison
1210 West Dayton Street, Madison WI  53706
Phone: 608.265.7829     FAX: 608.265-6453




More information about the jdom-interest mailing list