[Expat-discuss] Text data handler
Greg Martin
Greg.Martin at TELUS.COM
Fri May 21 16:45:14 EDT 2004
> -----Original Message-----
> From: expat-discuss-bounces at libexpat.org
> [mailto:expat-discuss-bounces at libexpat.org]On Behalf Of Thomás Inskip
> Sent: Friday, May 21, 2004 2:29 PM
> To: Karl Waclawek
> Cc: expat-discuss at libexpat.org
> Subject: Re: [Expat-discuss] Text data handler
>
>
> It turns out the problem is very different, and I had made an invalid
> assumption. There are two "outermost" xml elements being parsed, one
> after the other. The first one contains no element data (only
> attributes), but the second one does. So I am dealing with something
> that looks like:
>
> <a>
> <b attribute="value"></b>
> </a>
> <c>
> <d>some text</d>
> </c>
>
> But without the linefeeds. I had assumed that the problem
> was that my
> text callback handler was the problem because I already knew that my
> element start and end handlers were being called (for "a" and its
> sub-elements).
>
> The manual says something about needing a separate parser for each
> "document". What is the exact definition of a document? Is
> a document
> a data stream, or is the above two separate documents because
> there are
> two top-level elements (one defined by element a, and the
> other one by
> element d)? Perhaps Expat was not meant to do what I am asking it to
> do.
>
A couple of comments. First to your question ... a document can only have
one top-level element. You should check the return value of XML_Parse for
failure (I suspect it would have returned an error in your case) and if
you are passing all your data in one pass the final parameter of XML_Parse
should be true to indicate that it is your final call (or you should make a
final call to XML_Parse of length 0 and a fourth parameter == true).
More information about the Expat-discuss
mailing list