[xml] Re: How to catch DTD validation error while using xmlParseFile()



On Mon, Jul 29, 2002 at 10:25:43AM -0700, Gang Wang wrote:
I have an XML file which contains an internal DTD section, and I am using
xmlParseFile API. After setting xmlDoValidityCheckingDefaultValue to 1, when
there's a failure in DTD validatoin, libxml2 throws an error message to
stderr. However, it still returns a xmlDocPtr.  
My question is: How do I catch if there is any error in DTD so that I can
ignor the returned xmlDoc?

  Either catch the error, or use a more complex API based where
xmlParseDocument() is called directly with a parser context data
as the parameter and check ctxt->valid when returning from the
parser call. See xmlSAXParseFileWithData() in parser.c for
an example.

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]