xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gagan Gaur" <gagan_g...@dtius.com>
Subject Re: Bug
Date Thu, 09 Nov 2000 17:12:45 GMT
That's right,
The best way to remove nodes is to retrieve the last child and then remove
it. This would help you avoid any null pointer errors.

----- Original Message -----
From: Arnaud Le Hors <lehors@us.ibm.com>
To: <general@xml.apache.org>
Sent: Thursday, November 09, 2000 11:51 AM
Subject: Re: Bug


>
> From: Arnaud Le Hors <lehors@us.ibm.com> on 11/09/2000 08:51 AM
>
> Please respond to general@xml.apache.org
>
> To:   general@xml.apache.org
> cc:
> 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