1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
7 * \brief XML node getter/creation utilities
15 #include <yaz/xmalloc.h>
16 #include <yaz/xml_get.h>
19 const char *yaz_xml_get_prop(const xmlNode *n, const char *fmt, ...)
24 struct _xmlAttr *attr;
27 for (cp = fmt; *cp; cp++)
32 const char ***ar = xmalloc(sizeof(*ar) * no);
34 for (i = 0; i < no; i++)
36 const char **s = va_arg(ap, const char **);
39 for (attr = n->properties; attr; attr = attr->next)
41 const char *cp1 = fmt;
42 for (i = 0; *cp1; i++)
44 const char *cp2 = cp1;
46 while (*cp2 != '\0' && *cp2 != '%')
49 { /* no % following, break out (bad fmt really) */
54 if (l > 0 && strlen((const char *) attr->name) == l &&
55 !memcmp((const char *) attr->name, cp1, l))
59 cp1++; /* skip char following % */
63 /* attribute not listed in fmt: return first unknown one */
65 return (const char *) attr->name;
67 *ar[i] = (const char *) attr->children->content;
73 for (attr = n->properties; attr; attr = attr->next)
75 if (!strcmp((const char *) attr->name, fmt))
76 return (const char *) attr->children->content;
80 return 0; /* failure for simple mode; successful for %mode */
88 * c-file-style: "Stroustrup"
89 * indent-tabs-mode: nil
91 * vim: shiftwidth=4 tabstop=8 expandtab