About caracter handler and attribute value

東原正智 <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
Hi, I have two questions.
1. Can expat get attribute value ?
2. I write C program as folows.
but why on the first line of first cahracter data it cut root open
tag(<biblio>).

(program)
....
void char_handle(void *userdata,const XML_char *s,int len)
{
printf("[CHARACTERDATA] %s\n",s)
}

int main(int argc,char *argv[])
{
char buf[BUSFSIZE};
int eofflag;
size_t len;

XML_PARSER parser;
if((parser=XML_ParserCreate(NULL))==NULL){
fprintf(stderr,"parser creation error\n");
exit(-1);
}

XML_SetCharacterDataHandler(parser,char_handle);
do{
len=fread(buf,sizeof(char),BUFSIZE,stdin);
if(ferror(stdin)){
fprintf(stderr,"file error\n");
exit(-1);
}
eofflag=feof(stdin);
if((XML_Parser(parser,buf,(int)les,eofflag))==0){
fprintf(stderr,"parser error\n");
}
}while(!eofflag);
return 0;
}

(XML file)
<?xml version="1.0"?>
<biblio>
<book>
<author>aaa</author>
<title>bbb</title>
</book>
</biblio>

(output)
[Characterdata] <book id="1"> :<-why?
<author>aaa</author>
<title>bbb</title>
</book>
</biblio>
[Characterdata] <author>aaa</author>
<title>bbb</title>
</book>
</biblio>
[Characterdata] <title>bbb</title>
</book>
</biblio>
[Characterdata] </book>
</biblio>
[Characterdata] </biblio>

Please someone help me.
Regards

Masanori Higashihara

_______________________________________________
Expat-discuss mailing list
[email protected]
http://mail.libexpat.org/mailman/listinfo/expat-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.