xml_is: Checking an object's name

Previous: xml_attr*: Working with attributes ] [ Top: index ] [ Next: xml_search: Searching trees for elements ]

(July 8, 2001): OK, there was one more reason that XML * can't just be a void *. Eventually, XML structure will be completely opaque to the caller.
 
XMLAPI int xml_is (XML * xml, const char * name)
{
   if (!xml) return 0;
   if (!xml->name) return 0;
   if (!strcmp (xml->name, name)) return 1;
   return 0;
}
XMLAPI int xml_is_element (XML * xml)
{
   if (!xml) return 0;
   if (!xml->name) return 0;
   return 1;
}
July 18, 2001: Sheesh. This was a dumb omission.
 
XMLAPI const char * xml_name (XML * xml)
{
   if (!xml) return 0;
   return xml->name;
}
July 23, 2001: This has got to stop!
 
XMLAPI XML * xml_parent (XML * xml)
{
   if (!xml) return 0;
   return xml->parent;  /* Null if none, guaranteed. */
}
December 15, 2001: At least the binary extension is a new addition.
 
XMLAPI void * xml_getbin (XML * xml)
{
   if (!xml) return 0;
   return xml->extra;
}
XMLAPI void xml_setbin (XML * xml, void * bin, void (*cleanup) (void *))
{
   if (!xml) return;
   xml->extra = bin;
   xml->cleanup = cleanup;
}
September 19, 2003: Oooh. Extension to the API!
 
XMLAPI void xml_rename (XML * xml, const char * name)
{
   if (!xml) return;
   if (!name) return;
   free (xml->name);
   xml->name = strdup (name);
}
Previous: xml_attr*: Working with attributes ] [ Top: index ] [ Next: xml_search: Searching trees for elements ]


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.