XMLAPI void xml_replace (XML * xml, XML * newxml)
{
ELEMENTLIST * list;
if (xml == NULL) return;
if (xml->parent == NULL) return;
if (newxml == NULL) xml_delete (xml);
list = xml->parent->children;
while (list != NULL && list->element != xml) list = list->next;
if (list == NULL) return;
newxml->parent = xml->parent;
list->element = newxml;
xml_free (xml);
}
|
XMLAPI void xml_replacecontent (XML * parent, XML * child)
{
XML * first;
if (parent == NULL) return;
while (first = xml_first (parent)) {
xml_delete (first);
}
if (child != NULL) xml_prepend (parent, child);
}
|
XMLAPI void xml_replacewithcontent (XML * xml, XML * source)
{
ELEMENTLIST * list;
XML * src;
XML * target;
if (xml == NULL) return;
if (xml->parent == NULL) return;
if (source == NULL) xml_delete (xml);
list = xml->parent->children;
while (list != NULL && list->element != xml) list = list->next;
if (list == NULL) return;
src = xml_first (source);
if (!src) {
xml_delete (xml);
return;
}
target = xml_copy (src);
target->parent = xml->parent;
list->element = target;
src = xml_next (src);
while (src) {
target = xml_insertafter (target, xml_copy (src));
src = xml_next (src);
}
}
|
| This code and documentation are released under the terms of the GNU license. They are copyright (c) 2000-2003, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was created using LPML. |