xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lynch...@asus.com.tw
Subject RE: Bug
Date Fri, 10 Nov 2000 03:01:58 GMT
Hi

Then what should we do if we only want to remove a subset
from the NodeList? Say nodes 2 and 4 from 1,2,3,4, and 5,
according some logical comparison. I ask because I've tried
a little different approaches but none can avoid the null pointer
exception.

Regards
Lynch

> -----Original Message-----
> From: Arnaud Le Hors [mailto:lehors@us.ibm.com]
> Sent: Friday, November 10, 2000 12:51 AM
> To: general@xml.apache.org
> Subject: Re: Bug
> 
> 
> This is a very common mistake. NodeList objects are LIVE. This means
> everytime you remove a node all the indexes the contained 
> nodes and the
> length of the list get updated. The safest way to remove all the
> children of a node is to simply do something like:
> 
> while ((Node child = node.getLastChild()) != null)
>     node.removeChild(child);
> -- 
> Arnaud  Le Hors - IBM Cupertino, XML Technology Group
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
> 

Mime
View raw message