[jdom-interest] elt.getContent().iterator().remove() - a bug?

Noam Tamim noamt at yahoo.com
Mon Oct 1 11:30:11 PDT 2001


Hi.

I am trying to build a util that removes comments from XML files.
The relevant part is this method:

static void removeComments(Element e) {
  Iterator i=e.getContent().iterator();
  while (i.hasNext()) {
    Object o=i.next();
    if (o instanceof Comment) {
      System.out.println("removing: "+o);
      i.remove();
    }
    else if (o instanceof Element) removeComments((Element)o);
  }
}   

I successfully traverses the whole tree from the given Element down
(as seen by the "removing" line), yet not a single Comment is
removed.
Am I doing something wrong, or is that a (known?) bug?
I looked at the source of Element, PartialList, and LinkedList, and
found no answer.
Please help me.

-Noam.



__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com



More information about the jdom-interest mailing list