You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by 91change <91...@gmail.com> on 2009/03/19 06:05:27 UTC
Check valid xml file
Hi ,
I am using below code to parse the filename in configFile.c_str()
.... But eventhough i give a currupted xml file ( like some tags are missing
. some tags are opened but not closed ... i cannot catch any error ?????
.......)
MY utlimate aim is to find out if the xml file is proper one .
m_ConfigFileParser->setValidationScheme(XercesDOMParser::Val_Always);
m_ConfigFileParser->setDoNamespaces( true);
m_ConfigFileParser->setDoSchema( true);
m_ConfigFileParser->setValidationSchemaFullChecking(true);
m_ConfigFileParser->setDoValidation(true);
try
{
m_ConfigFileParser->parse( configFile.c_str() );
DOMDocument* xmlDoc = m_ConfigFileParser->getDocument();
DOMElement* elementRoot = xmlDoc->getDocumentElement();
if( !elementRoot )
{
throw(std::runtime_error(ERR_VALID_PARSE));
}
setDocument(xmlDoc);
} catch( ... )
{
cout << "error occured " ;
}
--
View this message in context: http://www.nabble.com/Check-valid-xml-file-tp22593831p22593831.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.
Re: Check valid xml file
Posted by 91change <91...@gmail.com>.
I tried a lot , but i m unable to catch execption ...... I tried with
xerces-3.0 ,...but not works ...
WORKAROUND .....You can use error handler
m_ConfigFileParser->setValidationScheme( XercesDOMParser::Val_Auto
);
m_ConfigFileParser->setDoNamespaces( true );
m_ConfigFileParser->setDoSchema( true );
m_ConfigFileParser->setValidationSchemaFullChecking(true);
DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
m_ConfigFileParser->setErrorHandler(errReporter);
Please find files DOMTreeErrorReporter.cpp and DOMTreeErrorReporter.hpp
in xerces for better understanding .....
Thanks.................................................................................
--
View this message in context: http://www.nabble.com/Check-valid-xml-file-tp22593831p22633262.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.