rt-thread/examples/gui/demo_xml.c
dzzxzz@gmail.com 9a99573152 sync gui examples with github 6cf0a8bc19c292ca810c917574895c8defa3922e
As always, full log is in GitHub.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2254 bbd45198-f89e-11dd-88c7-29a3b14d5316
2012-08-13 08:32:01 +00:00

27 lines
726 B
C

#include <rtthread.h>
#include <rtgui/rtgui_xml.h>
static int xml_event_handler(rt_uint8_t event, const char *text, rt_size_t len, void *user)
{
rt_kprintf("%s: %s\n", rtgui_xml_event_str(event), text);
return 1;
}
const char xml_str[] = "<?xml version=\"1.0\"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>";
void demo_xml()
{
rtgui_xml_t *xml;
xml = rtgui_xml_create(512, xml_event_handler, RT_NULL);
if (xml != RT_NULL)
{
rtgui_xml_parse(xml, xml_str, sizeof(xml_str));
rtgui_xml_destroy(xml);
}
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(demo_xml, show the demo of xml parser);
#endif