xml_attr*: Working with attributes

Previous: xml_copy: making fresh copies of XML ] [ Top: index ] [ Next: xml_is: Checking an object's name ]

(May 27, 2001): it's turning out that the only place the wftk really knows anything about the internals of the XMLAPI is when it has to iterate through attributes. This is a bad situation, because it prevents me from creating alternate XMLAPI libraries to work with different environments (this all occurred to me as I was musing about the best way to make an XMLAPI that takes advantage of the Python heap manager when working in a Python environment). So the attribute functions will be xml_attrfirst, xml_attrnext, xml_attrname and xml_attrvalue. The unfortunate similarity to xml_attrval is, well, unfortunate, but I've written too much code that works with xml_attrval to go back and change it now. Them's the breaks when you design an API on the fly, I guess.

Let's do the iteration functions first; they're interesting. The other two are boring.
 
XMLAPI XML_ATTR * xml_attrfirst (XML * element)
{
   if (!element) return NULL;
   return element->attrs;
}
XMLAPI XML_ATTR * xml_attrnext (XML_ATTR * attr)
{
   if (!attr) return NULL;
   return attr->next;
}
OK, let's mop up the boring pieces, then.
 
const char *xml_attrname  (XML_ATTR * attr) { return (attr->name);  }
const char *xml_attrvalue (XML_ATTR * attr) { return (attr->value); }
So, OK, it's pretty stupid that I never got around to writing code of that much complexity... Sheesh.
Previous: xml_copy: making fresh copies of XML ] [ Top: index ] [ Next: xml_is: Checking an object's name ]


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.