Xerces C++ problem if XML file not present

G

Greg O'Rawe

Hi,

I am using the Xerces C++ parser API (2.3.0) on Solaris 2.8 and am getting a
problem if I try to parse a file which does not exist.

Here's the code:

XercesDOMParser *parser = new XercesDOMParser;

try
{
parser->parse(file.data());
}
catch (const XMLException& xmlException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse XML file %s, cause = $s", file,
xmlException.getMessage());
return false;
}
catch (const DOMException& domException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse DOM file %s, code = $s", file, domException.code);
return false;
}
catch (...)
{
logError("ConfigFileReader::ReadGeneralConfigFile An unknown error
occurred attempting to parse XML file %s", file);
return false;
}

Everything is fine if the XML file exists and it is parsed without problem.
However if the file does not exist an exception is not thrown and the
program continues to try and traverse the doucment tree (which does not
exist of course). Even the (...) catch-all exception is not run.

Is there anything I have missed here? I can't see anything from the sample
Xerces stuff and the API documentation.

Many thanks

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top