Re: [xml] How to know that the parser has stopped (or aborted) in python



On Wed, Feb 08, 2006 at 05:59:53PM +0100, Cesar Ortiz wrote:
Hi,

Perhaps I should ask this to
xml-bindings gnome org<http://mail.gnome.org/mailman/listinfo/xml-bindings>but
looking into the archives, they are quite old. Is that list still
working?
Anyway I have not manage to find something useful...

Looking at C examples that uses the function htmlParseChunk  I have seen
this:

ctxt = htmlCreatePushParserCtxt(
SAXHandler, &abort, buf, res, argv[1], 0);

while ( !abort && (res = fread(buf, 1, 2048, f)) > 0)
  htmlParseChunk(ctxt, buf, res, 0);

Checking 'abort', you know that something has gone wrong and you have to
stop to pushing chunks to the parser.  How you should do this in python?

  you're using the HTML parser, which should never abort basically.
The notion of fatal error where the parser stops emitting data (just more
error message) exists only in the XML parser.

Daniel

-- 
Daniel Veillard      | Red Hat http://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]