xml_append: Inserting elements

Previous: xml_prepend: Inserting elements ] [ Top: index ] [ Next: xml_replace and xml_replacecontent: Replacing an element with another. ]

It's appending where we run into problems.
 
XMLAPI void xml_append (XML * parent, XML * child)
{
   ELEMENTLIST * list;
   ELEMENTLIST * ch;

   child->parent = parent;

   list = (ELEMENTLIST *) MALLOC (sizeof(struct _list));
   list->element = child;
   list->prev = NULL;
   list->next = NULL;

   if (parent->children == NULL) {
      parent->children = list;
      return;
   }

   ch = parent->children;
   while (ch->next != NULL) ch = ch->next;
   list->prev = ch;
   ch->next = list;
}
Previous: xml_prepend: Inserting elements ] [ Top: index ] [ Next: xml_replace and xml_replacecontent: Replacing an element with another. ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was created using LPML.