static void text(GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error) { if (current_animal_noise) printf("I am a %*s and I go %s. Can you do it?\n", text_len, text, current_animal_noise); printf("test text\n"); }
GMarkupParser parser = { .start_element = start, .end_element = end, .text = text, .passthrough = NULL, .error = NULL };
int main() { char *buf; gsize length; GMarkupParseContext *context; g_file_get_contents("test.xml", &buf, &length,NULL); g_printf("%s\n",buf); context = g_markup_parse_context_new(&parser, 0, NULL, NULL); if (g_markup_parse_context_parse(context, buf, length, NULL) == FALSE) { printf("Couldn't load xml\n");
g_markup_parse_context_free(context); return 0; }
|