#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
static void xml_start(GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer data,
GError **error)
{
const gchar *element;
element = g_markup_parse_context_get_element(context);
}
static void xml_end(GMarkupParseContext *context,
const gchar *element_name,
gpointer data,
GError **error)
{
const gchar *element;
element = g_markup_parse_context_get_element(context);
}
static void xml_element(GMarkupParseContext *context,
const gchar *text,
gsize text_len,
gpointer data,
GError **error)
{
const gchar *element;
element = g_markup_parse_context_get_element(context);
printf("> element : %s\n", (char*)element);
}
static void xml_err(GMarkupParseContext *context,
GError *error,
gpointer data)
{
g_printerr("error: %s\n", error->message);
}
int _tmain(int argc, _TCHAR* argv[])
{
gchar* content = "C:\fc.xml";
static GMarkupParser parser = { xml_start, xml_end, xml_element, NULL, xml_err };
GMarkupParseContext *context;
context = g_markup_parse_context_new (&parser, G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG, NULL, NULL);
g_markup_parse_context_parse (context, "C:\fc.xml", -1, NULL);
g_markup_parse_context_free (context);
system("pause");
return 0;
}
Partager