You might try iterating backwards through the list.  I would assume that removing a child might change the indexing of the rest of the children, if your start at lists.size() - 1 and work your way toward 0, then the rest of the indexes won't change.<div>

  (*Chris*)<br><br><div class="gmail_quote">On Mon, Apr 9, 2012 at 12:39 PM, Bashiro <span dir="ltr"><<a href="mailto:bashiro@myway.com">bashiro@myway.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thanks a lot for the reply. And thanks to both Rolf and Chris!<br>
I really appreciate this.<br>
<br>
What I am doing is; I am searching for  an "ID" in "contacts" to delete.<br>
I have the following code-><br>
<br>
 List lists;<br>
 Element  next;<br>
<br>
 lists = document.getRootElement().getChildren();<br>
        for (int i = 0; i < lists.size(); i++) {<br>
            next = (Element) lists.get(i);<br>
            if (next.getAttribute("contacts").getValue().equals(ID)) {<br>
                    next.getAttribute("name").getValue();<br>
                    next.getAttribute("address").getValue();<br>
                    next.getAttribute("tel").getValue();<br>
                    next.getAttribute("mobile").getValue();<br>
                  next.detach();<br>
<br>
This only works when the ID  in question is at [0]. I can view the contacts in a table too.<br>
If the contact is in a second row or a different row than first row it does not work.<br>
<br>
I even tried this;<br>
 if (next.getAttribute("contacts").getValue().equals(ID)&&next.getAttribute("name").getValue().equals(name)) {<br>
do.....<br>
}<br>
<br>
Thanks for any help.<br>
<br>
Have a nice day!<br>
<br>
bashiro<br>
                    next.detach();<br>
                System.out.println("REMOVED  LAST " + domainName + "\n");<br>
<br>
Bashiro<br>
Drammen-Norway<br>
<div><div class="h5"><br>
-----Original Message-----<br>
From: "Rolf Lear" [<a href="mailto:jdom@tuis.net">jdom@tuis.net</a>]<br>
Date: 04/09/2012 19:36<br>
To: "Bashiro" <<a href="mailto:bashiro@myway.com">bashiro@myway.com</a>><br>
CC: <a href="mailto:jdom-interest@jdom.org">jdom-interest@jdom.org</a><br>
Subject: Re: [jdom-interest] Removing Elements<br>
<br>
<br>
Hi Brashiro.<br>
<br>
I think (at least I hope) you are mistaken.<br>
<br>
You should be able to remove an Element in a number of ways....<br>
<br>
Assuming that you have a Element emt which is item 3 in the 'parent'<br>
ContentList, you should be able to do any one of:<br>
<br>
emt.detach();<br>
parent.removeContent(emt);<br>
parent.getContent().remove(3);<br>
<br>
Rolf<br>
<br>
<br>
<br>
<br>
On Mon, 09 Apr 2012 12:47:56 -0400, "Bashiro" <<a href="mailto:bashiro@myway.com">bashiro@myway.com</a>> wrote:<br>
> Hello Folks!<br>
> First of all thanks to the jDom team for version 2.0!<br>
> Congrats to us all...<br>
><br>
> My question is; I am trying to remove an element in jDom. It only<br>
removes<br>
> the element if<br>
> the element is located at [0].  Is there a good code or a good book to<br>
> help me with that ?<br>
><br>
> Thanks<br>
><br>
> Bashiro<br>
> Drammen-Norway<br>
><br>
> _______________________________________________<br>
> To control your jdom-interest membership:<br>
</div></div>> <a href="mailto:youraddr@yourhost.com">youraddr@yourhost.com</a>"><a href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" target="_blank">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br>


<br>
<br>
</blockquote></div><br></div>