xml_copy.
XMLAPI XML * xml_copy (XML * orig)
{
XML * copy = NULL;
XML * child;
ATTR * attr;
if (!orig) return copy;
if (!orig->name) {
if (!orig->attrs) copy = xml_createtext ("");
else if (!orig->attrs->value) copy = xml_createtext ("");
else copy = xml_createtext (orig->attrs->value);
return copy;
}
copy = xml_create (orig->name);
attr = orig->attrs;
while (attr) {
xml_set (copy, attr->name, attr->value);
attr = attr->next;
}
child = xml_first (orig);
while (child) {
xml_append (copy, xml_copy (child));
child = xml_next (child);
}
return (copy);
}
|
XMLAPI XML * xml_copyinto (XML * target, XML * source)
{
XML * child;
ATTR * attr;
if (!source) return target;
if (!source->name) {
if (target) {
if (source->attrs) if (source->attrs->value) xml_append (target, xml_createtext (source->attrs->value));
return (target);
}
if (source->attrs) if (source->attrs->value) target = xml_createtext (source->attrs->value);
return (target);
}
if (!target) target = xml_create (source->name);
attr = source->attrs;
while (attr) {
xml_set (target, attr->name, attr->value);
attr = attr->next;
}
child = xml_first (source);
while (child) {
xml_append (target, xml_copy (child));
child = xml_next (child);
}
return (target);
}
|
XMLAPI XML * xml_copyattrs (XML * target, XML * source)
{
ATTR * attr;
if (!source) return target;
if (!source->name) {
if (target) return (target);
if (source->attrs) if (source->attrs->value) target = xml_createtext (source->attrs->value);
return (target);
}
if (!target) target = xml_create (source->name);
attr = source->attrs;
while (attr) {
xml_set (target, attr->name, attr->value);
attr = attr->next;
}
return (target);
}
|
| 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. |