[jdom-interest] Confused over getChildren()

adam flinton aflinton at armature.com
Tue Nov 27 08:17:01 PST 2001


Dear All,

E.g. imagine a structure such as:

<MyElement>
<ElementA>
<ElementA>
<ElementA>
<ElementA>
<ElementB>
<ElementC>
<ElementD>
</MyElement>

If I call

List L = MyDoc.getRootElement().getChildren(ElementA);

I get back a List of 4 elements. OK so far.

If I then add a new ElementA however what I get is:

<MyElement>
<ElementA>
<ElementA>
<ElementA>
<ElementA>
<ElementB>
<ElementC>
<ElementD>
<ElementA>
</MyElement>

Is this normal behaviour (JDOM Beta 7) or a bug?

i.e. what I would expect to see (having read the docs) is:

<MyElement>
<ElementA>
<ElementA>
<ElementA>
<ElementA>
<ElementA>
<ElementB>
<ElementC>
<ElementD>
</MyElement>

If this is normal/expected then possibly a note in the docs to say use
getChildren() (without giving the name of the Element & then work out the
ordinality of the elements for yourself might be of help as otherwise it
looks as if by adding to the list of 4 elements you should get 5 of the same
elements one after the other.


Adam Flinton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20011127/abdaf524/attachment.htm


More information about the jdom-interest mailing list