| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#include "sflxml.h" int xml_put_attr ( XML_ITEM *item, const char *name, const char *value)
Sets, modifies, or deletes an attribute for the specified item. The attribute name must be supplied. If the value is NULL, any attribute with the specified name is deleted. Otherwise the specified attribute is either created or modified accordingly. Returns the number of attribute nodes created (-1, 0, or 1).
{ int feedback = 0; XML_ATTR *attr; ASSERT (item); ASSERT (name); attr = xml attr (item, name); if (attr) if (value) /* Value specified - update attr */ { mem_strfree (&attr-> value); attr-> value = mem_strdup (value); } else { xml free attr (attr); /* No value - delete attribute */ feedback = -1; } else if (value) /* Value specified - update attr */ { list_create (attr, sizeof (XML_ATTR)); if (attr) { attr-> name = mem_strdup (name); attr-> value = mem_strdup (value); attr-> parent = item; list_relink_before (attr, &item-> attrs); feedback = 1; } } return (feedback); }
| << | < | > | >> |
![]() |