Re: Getting xml element data...

Jez Higgins <[email protected]>
Newsgroups gmane.text.xml.expat.general
Organization Jez UK Ltd
Message-ID <[email protected]>
Nikola wrote:
> Hello,
> 
> I am trying to parse simple xml file and process text value in elements 
> (eg. <e>some text</e>).
> but when my "processText" functions gets called on text element....it 
> also contains ending tag.....
> 
> How can I get only text....i am sure that library is not designed to 
> return ending tag in text value
> of xml element.
> 
> I accept posibility that I am doing soemthing wrong.....
> 

You are :)

> static void XMLCALL
> processText(void *userData, const char *data, int len)
> {
>    
>     if(status && !strcmp(gname,"data")){
>         printf("[%s]",data);
>         status = 0;
>     }
> }

You are treating data as a pointer to a nul-terminated string.  It
isn't.  It points into the buffer expat is parsing.  The len parameter
tell you the end point of the character data.

The text you want is from data to data+len.  In the example you've given
you could use a loop and putchar to output it.

Jez

_______________________________________________
Expat-discuss mailing list
[email protected]
http://mail.libexpat.org/mailman/listinfo/expat-discuss
signature.asc (application/pgp-signature, 250 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEwJikd5Jqiw9+jCsRArGLAKC7jTlE46BdFV4LgnYkyDgmO6TeHQCcCNDp
axgepM9Sb1vEy+5kSthOe10=
=ZnUJ
-----END PGP SIGNATURE-----
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.