2012-04-18 23:06:12 +08:00
# include <rtthread.h>
# include <rtgui/rtgui_xml.h>
2012-08-13 16:32:01 +08:00
static int xml_event_handler ( rt_uint8_t event , const char * text , rt_size_t len , void * user )
2012-04-18 23:06:12 +08:00
{
2012-08-13 16:32:01 +08:00
rt_kprintf ( " %s: %s \n " , rtgui_xml_event_str ( event ) , text ) ;
return 1 ;
2012-04-18 23:06:12 +08:00
}
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 ( )
{
2012-08-13 16:32:01 +08:00
rtgui_xml_t * xml ;
2012-04-18 23:06:12 +08:00
2012-08-13 16:32:01 +08:00
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 ) ;
}
2012-04-18 23:06:12 +08:00
}
# ifdef RT_USING_FINSH
# include <finsh.h>
FINSH_FUNCTION_EXPORT ( demo_xml , show the demo of xml parser ) ;
# endif