You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Sudheer Tumuluru <st...@real.com> on 2000/07/26 02:05:18 UTC
Exceptions on Invalid XML Document
Hi,
I wrote an XML DOM Parser with Xerces and it works just fine
when I pass a vaild document string to the parse() method. But it does
not throw any exception when an invalid document is passed. Later, when
I attempt to read it, DOM_Element::getTagName() throws a fatal error
which I couldn't catch by putting it in a "XMLException" try-catch
block. Should I be looking for any exceptions other than the
XMLException?
Thanks in advance,
Sudheer
--
------------------------------------------------------------------------
Sudheer Tumuluru
stumuluru@real.com
Software Development Engineer, Real Broadcast Network
RealNetworks Inc. http://www.realnetworks.com
------------------------------------------------------------------------
RE: Exceptions on Invalid XML Document
Posted by John Roper <Jo...@iOra.com>.
Hi Sudheer,
You need to supply an error handler to the parser. Here's one I prepared
earlier that you are welcome to use.
Hope this helps
John Roper
iOra Ltd.
www.iora.com
class CDOMErrorHandler : public ErrorHandler
{
public:
CDOMErrorHandler()
{
resetErrors();
}
virtual ~CDOMErrorHandler()
{
}
void fatalError(const SAXParseException& e)
{
m_hadError = TRUE;
}
void error(const SAXParseException& e)
{
m_hadError = TRUE;
}
void warning(const SAXParseException& e)
{
m_hadError = TRUE;
}
void resetErrors()
{
m_hadError = FALSE;
}
BOOL m_hadError;
};
....
try
{
DOMParser Parser;
CDOMErrorHandler errorHandler;
Parser.setErrorHandler( (ErrorHandler*) &errorHandler);
Parser.parse( xmlFile );
if ( errorHandler.m_hadError )
{
stop!!
-----Original Message-----
From: stumuluru@prognet.com [mailto:stumuluru@prognet.com]On Behalf Of
Sudheer Tumuluru
Sent: 26 July 2000 01:05
To: XML Apache Mailing List
Subject: Exceptions on Invalid XML Document
Hi,
I wrote an XML DOM Parser with Xerces and it works just fine
when I pass a vaild document string to the parse() method. But it does
not throw any exception when an invalid document is passed. Later, when
I attempt to read it, DOM_Element::getTagName() throws a fatal error
which I couldn't catch by putting it in a "XMLException" try-catch
block. Should I be looking for any exceptions other than the
XMLException?
Thanks in advance,
Sudheer
--
------------------------------------------------------------------------
Sudheer Tumuluru
stumuluru@real.com
Software Development Engineer, Real Broadcast Network
RealNetworks Inc. http://www.realnetworks.com
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org