Re: [xml] stop saxparsing?



On Mon, Feb 09, 2004 at 06:14:09PM +0100, aliban gmx net wrote:
hi.
my parser reads a document and while it does this there might come 
some "tag" that should make the object doing the job to get deleted. 
whatever if i delete the memory that holds the document my 
application crashs (probably because the document was not finished...

example:

static void x_endElement(void *ctx,const xmlChar *fullname)
{
      ...
      </some special element>
      xmlFreeParserCtxt(((myclass*)ctx)->ptxmlParserCtx);
      // or maybe even
      delete (myclass*)ctx;
      ...
}

this crashs my app. how do i delete/free the memory of the parser if 
a special event (in the doc) appears?

  You can't do that ! Sax is callback based. You cannot break the flow of 
control from *within* a callback. Check xmlStopParser() but you simply
can't destroy the parser when you're called from within the parser !

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]