1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
22
static void mstr(char *str,const char *src,uint l1,uint l2)
29
static int dstr(MY_XML_PARSER *st,const char *attr, uint len)
33
mstr(str,attr,len,sizeof(str)-1);
34
printf("VALUE '%s'\n",str);
38
static int bstr(MY_XML_PARSER *st,const char *attr, uint len)
42
mstr(str,attr,len,sizeof(str)-1);
43
printf("ENTER %s\n",str);
48
static int estr(MY_XML_PARSER *st,const char *attr, uint len)
52
mstr(str,attr,len,sizeof(str)-1);
53
printf("LEAVE %s\n",str);
57
static void usage(const char *prog)
60
printf("%s xmlfile\n",prog);
63
int main(int ac, char **av)
77
fn=av[1]?av[1]:"test.xml";
78
if ((f=open(fn,O_RDONLY))<0)
80
fprintf(stderr,"Err '%s'\n",fn);
84
len=read(f,str,sizeof(str)-1);
87
my_xml_parser_create(&p);
89
my_xml_set_enter_handler(&p,bstr);
90
my_xml_set_value_handler(&p,dstr);
91
my_xml_set_leave_handler(&p,estr);
93
if (MY_XML_OK!=(f=my_xml_parse(&p,str,len)))
95
printf("ERROR at line %d pos %d '%s'\n",
96
my_xml_error_lineno(&p)+1,
98
my_xml_error_string(&p));
101
my_xml_parser_free(&p);