[jdom-interest] Element.getChildren() problem

Sasha Bilton Sasha.Bilton at alisonassociates.com
Wed Aug 29 09:04:28 PDT 2001

> -----Original Message-----
> From: MarkW [mailto:markw at wilsoncom.de]

> Hi!
> This doesn´t work:
> List list = doc.getRootElement().getChildren("child");
> it just returns the element with local name "child"

As it should do if you have one <child/> element 

It'll get multiple <child> elements if there are more than one (I checked)
> but this does:
> List list = doc.getRootElement().getChild("child").getChildren();

This would mean your xml should look like this and return <grandchild>

I think what you want is...

Iterator i = doc.getRootElement().getChildren("child").iterator();
	Element child = (Element)i.next();
	Iterator i2 = child.getChildren().iterator();
		Your code here


Alison Associates

The information contained in this e-mail and any attached files is intended only for the use of the person(s) to whom it is addressed and may be privileged, confidential and exempt from disclosure under applicable law. The views of the author may not necessarily reflect the views of the Company. If you are not the intended recipient please do not copy or convey this message or any attached files to any other person but delete this message and any attached files and notify us of incorrect receipt via e-mail to mailadmin at alisonassociates.com. 

This message has been checked for all known viruses by MessageLabs.

More information about the jdom-interest mailing list