Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
removing element from document

removing element from document

2007-12-06       - By rolf.lear@(protected)

 Back
Reply:     1     2     3  

Just change the inside of the loop from:

                     //throws ConcurrentModificationException
                     feature.getChild("FIELDS").removeContent(field);

to:

                     //throws ConcurrentModificationException
                     j.remove();

It is 'well-documented' that if you have an integrator, you can't change
the collection apon which the iterator is based, unless you use the
iterator to make the change. See the ConcurrentModificationException
javadoc.

Rolf

-- --Original Message-- --
From: jdom-interest-bounces@(protected)
[mailto:jdom-interest-bounces@(protected)] On Behalf Of John Cartwright
Sent: Thursday, December 06, 2007 2:10 PM
To: jdom-interest@(protected)
Subject: [jdom-interest] removing element from document

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
ConcurrentModificationException.

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

Thanks!

-- john

       
         List features =
root.getChild("RESPONSE").getChild("FEATURES").getChildren("FEATURE");
         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
                     feature.getChild("FIELDS").removeContent(field);
                 }
             }            
         }

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
This email and any files transmitted with it are confidential and proprietary
to Algorithmics Incorporated and its affiliates ("Algorithmics"). If received
in error, use is prohibited. Please destroy, and notify sender. Sender does not
waive confidentiality or privilege. Internet communications cannot be
guaranteed to be timely, secure, error or virus-free. Algorithmics does not
accept liability for any errors or omissions. Any commitment intended to bind
Algorithmics must be reduced to writing and signed by an authorized signatory.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.