[jdom-interest] Re: Only getting the first element node
Brett McLaughlin
brett.mclaughlin at lutris.com
Tue Oct 10 09:24:42 PDT 2000
David Parker wrote:
>
> 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();
Can you post your XML document?
-Brett
>
> >>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
>
> _______________________________________________
> 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