<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>Confused over getChildren()</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Dear All,</FONT>
</P>
<P><FONT SIZE=2>E.g. imagine a structure such as:</FONT>
</P>
<P><FONT SIZE=2><MyElement></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementB></FONT>
<BR><FONT SIZE=2><ElementC></FONT>
<BR><FONT SIZE=2><ElementD></FONT>
<BR><FONT SIZE=2></MyElement></FONT>
</P>
<P><FONT SIZE=2>If I call</FONT>
</P>
<P><FONT SIZE=2>List L = MyDoc.getRootElement().getChildren(ElementA);</FONT>
</P>
<P><FONT SIZE=2>I get back a List of 4 elements. OK so far.</FONT>
</P>
<P><FONT SIZE=2>If I then add a new ElementA however what I get is:</FONT>
</P>
<P><FONT SIZE=2><MyElement></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementB></FONT>
<BR><FONT SIZE=2><ElementC></FONT>
<BR><FONT SIZE=2><ElementD></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2></MyElement></FONT>
</P>
<P><FONT SIZE=2>Is this normal behaviour (JDOM Beta 7) or a bug?</FONT>
</P>
<P><FONT SIZE=2>i.e. what I would expect to see (having read the docs) is:</FONT>
</P>
<P><FONT SIZE=2><MyElement></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementA></FONT>
<BR><FONT SIZE=2><ElementB></FONT>
<BR><FONT SIZE=2><ElementC></FONT>
<BR><FONT SIZE=2><ElementD></FONT>
<BR><FONT SIZE=2></MyElement></FONT>
</P>
<P><FONT SIZE=2>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.</FONT></P>
<BR>
<P><FONT SIZE=2>Adam Flinton</FONT>
</P>
</BODY>
</HTML>