Re: [xml] Avoid displaying libxml error messages in my program

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Fri Nov 26 1999 - 13:00:56 EST


On Fri, Nov 26, 1999 at 04:07:49PM +0000, Fernando_Pereira@amsinc.com wrote:
>
>
>
> Hi all,
>
> Can anyone tell me how to avoid the display of libxml error messages to the
> screen?
> Is there a macro or a define in one of the modules that I can use for this?
>
> Kind regards,

  The errors are displayed by the parser using the function registred
in the SAX callback list. E.g:

xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
 ...
    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
        ctxt->sax->error(ctxt->userData, "Unfinished SystemLiteral\n");

The point is to make ctxt->sax->error and ctxt->sax->warning
NULL or pointing to your own function. They are initialized by
default to

xmlParserError(void *ctx, const char *msg, ...)
and
xmlParserWarning(void *ctx, const char *msg, ...)

found in error.c

So use create your own xmlSAXHandlerPtr by copying the default one
with error and warning initialized to your need and call

xmlDocPtr
xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename, 0);

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux, WWW, rpmfind,
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | rpm2html, XML,
http://www.w3.org/People/W3Cpeople.html#Veillard | badminton, and Kaffe.
----
Message from the list xml@rufus.w3.org
Archived at : http://rufus.w3.org/veillard/XML/messages
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rufus.w3.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:53 EDT