Re: [xml] A question on xmlUnlinkNode()



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]