[jdom-interest] Element.getChildren(java.lang.String name)?

GB/DEV - Philip Nelson philip.nelson at omniresources.com
Wed Mar 7 06:56:29 PST 2001


> I see what you mean. However I'm trying to use an Iterator to 
> "iterate"
> through this.
> 
> Element root = doc.getRootElement() // complexType
> 
> java.util.Iterator iter = root.getChildren("sequence").iterator();
> while (iter.hasNext())
> {
> 	org.jdom.Element elem = (org.jdom.Element) iter.next();
> 	System.out.println(elem.getName());
> }
> 
> > 
> > <complexType name="RepositoryType">
> > 	<sequence>
> > 		<element name="IRObject" type="IRObjectType"/>
> > 		...
> > 		...
> > 	</sequence>
> > </complexType>

Your code looks right if you want to iterate through sequences.  You will
have to go one layer deeper to iterate through elements.



More information about the jdom-interest mailing list