[jdom-interest] Re: Only getting the first element node

David Parker dlparker at facstaff.wisc.edu
Tue Oct 10 08:54:48 PDT 2000


Updated to version beta 5 and still seeing only first element
Is there a problem with setting the list from the root?
The size of the list is 1.

>         // Get the root element
>         org.jdom.Element root = jdomDoc.getRootElement();
>
>         List mycourse = root.getChildren();             //return all children

         java.util.Iterator iter = mycourse .iterator();
         davDebug += "Size of myCourses list: " + mycourse .size();


 >>Are you using beta 5? If not, you need to.
 >>Try that and let us know. -Brett


>Date: Mon, 09 Oct 2000 18:27:56 -0500
>To: jdom-interest at jdom.org
>From: David Parker <dlparker at facstaff.wisc.edu>
>Subject: Only getting the first element node
>Bcc: David Parker <dlparker at facstaff.wisc.edu>
>
>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