[jdom-interest] Only getting the first element node

Brett McLaughlin brett.mclaughlin at lutris.com
Mon Oct 9 17:28:46 PDT 2000


David Parker wrote:
> 
> 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?

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

-Brett

> -------------------------------------------------------------------------------------------------------------------------------------
> 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
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list