[jdom-interest] removing element from document

John Cartwright John.C.Cartwright at noaa.gov
Thu Dec 6 11:09:46 PST 2007

Hello All,

I need to remove all the Elements from a Document who have a particular 
attribute w/ a particular value.  My first (unsuccessful) attempt was 
Element#removeContent w/in an iterator loop which throws a 

Can someone suggest to me the correct way to do this sort of thing?


-- john

          List features = 
          for (Iterator i=features.iterator();i.hasNext();) {
              feature = (Element) i.next();
              fields = feature.getChild("FIELDS").getChildren("FIELD");
              for (Iterator j=fields.iterator(); j.hasNext();) {
                  field = (Element)j.next();
                  if ("#SHAPE#".equals(field.getAttributeValue("name"))) {
                      //throws ConcurrentModificationException

More information about the jdom-interest mailing list