#include "xml.h" /* parse a string into a document */ struct kai_tag_t * kai_parse_string(const char *str) { yyscan_t scanner; struct kai_tag_t *document; kalmialex_init(&scanner); YY_BUFFER_STATE buf = kalmia_scan_string(str, scanner); int result = kalmiaparse(scanner, &document); kalmia_delete_buffer(buf, scanner); kalmialex_destroy(scanner); if (result != 0) { return NULL; } return document; } char * kai_tag_get_attr(struct kai_tag_t *t, const char *attr) { struct kai_attr_t *a = t->attrs; while (a != NULL) { if (strcmp(a->key, attr) == 0) { return a->value; } a = a->next; } return NULL; }