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
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to