[Expat-discuss] [expat] newbie question
Andre Luis Monteiro
andrelsm at iname.com
Mon Apr 9 15:37:26 CEST 2007
Jeffrey
you should to use
XML_Bool XMLCALL XML_ParserReset(XML_Parser p, const XML_Char *encoding);
Clean up the memory structures maintained by the parser so that it may be used again. After this has been called, parser is ready to start parsing a new document. All handlers are cleared from the parser, except for the unknownEncodingHandler. The parser's external state is re-initialized except for the values of ns and ns_triplets. This function may not be used on a parser created using XML_ExternalEntityParserCreate; it will return XML_FALSE in that case. Returns XML_TRUE on success. Your application is responsible for dealing with any memory associated with user data.
regards
André Luís
PS: take a glance at your expat-2.0.0/doc/reference.html
> ----- Original Message -----
> From: "Nick MacDonald" <nickmacd at gmail.com>
> To: jeffreyholle at bellsouth.net
> Subject: Re: [Expat-discuss] [expat] newbie question
> Date: Sun, 8 Apr 2007 23:18:21 -0400
>
>
> Jeffrey:
>
> I think you need to make a new instance of the parser for each file.
> What you are doing has the overall effect of concatenating the files
> together one ofter the other, which would not be legal because there
> can only be one main XML element (my terminology may be off here) per
> file. Unfortunately I am not near a machine with my own code and not
> on a machine that has (or can have) eXpat installed. But in
> pseudo-code, do this:
>
> while (more files)
> {
> parser=createParser()
> open(file)
> while(!eof)
> {
> read databuff
> xmlParse(databuff)
> }
> close(file)
> finalizeParser()
> }
>
> Good luck,
> Nick
>
> On 4/8/07, Jeffrey Holle <jeffreyholle at bellsouth.net> wrote:
> > I'm using expat 2.0.0 self build on Ubuntu Linux 5.10.
> >
> > The program that I'm writing needs to process N XML files.
> > Note not nested, but in series.
> >
> > My first attempt initializes the expat parser and feeds the data into it
> > like this (pseudo code):
> >
> > while(!files.eof())
> > {
> > getline(files.filename);
> > ifstream file(filename);
> > do {
> > char buffer[256];
> > file.read(buffer,256);
> > XML_Parse(parser,buffer,file.gcount(),0);
> > } while (file.eof());
> > XML_Parse(parser,NULL,0,1);
> > }
> >
> > I have not shown it, but I do have an element handler enabled and it
> > works as expected for the first file, but not subsequent ones.
> >
> > What should I be doing to end one XML file parsing action and start another?
> >
> > _______________________________________________
> > Expat-discuss mailing list
> > Expat-discuss at libexpat.org
> > http://mail.libexpat.org/mailman/listinfo/expat-discuss
> >
>
>
> --
> Nick MacDonald
> NickMacD at gmail.com
> _______________________________________________
> Expat-discuss mailing list
> Expat-discuss at libexpat.org
> http://mail.libexpat.org/mailman/listinfo/expat-discuss
>
abraço
André Luís
=
More information about the Expat-discuss
mailing list