[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] A question on xmlUnlinkNode()
- From: Petr Pajas <pajas ufal mff cuni cz>
- To: xml gnome org
- Subject: Re: [xml] A question on xmlUnlinkNode()
- Date: Wed, 1 Nov 2006 16:04:12 +0100
On Wednesday 01 November 2006 16:00, Daniel Haude wrote:
> Hello all,
>
> With the following code snippet I'm trying to wipe out all
> contents of a given xmlNode "cell":
>
> xmlNode *no;
>
> for (no = cell->children; no; no = no->next) {
> xmlUnlinkNode(no);
> }
...
> Why doesn't this work?
Because you are modifying the very same list you are traversing.
Try something like:
for (no = cell->children; no;) {
next = no->next;
xmlUnlinkNode(no);
no=next;
}
-- Petr
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]