Xerces C++ problem if XML file not present

Discussion in 'XML' started by Greg O'Rawe, Nov 21, 2003.

  1. Greg O'Rawe

    Greg O'Rawe Guest

    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
     
    Greg O'Rawe, Nov 21, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ralf Wahner
    Replies:
    5
    Views:
    655
    Bob Foster
    Dec 24, 2003
  2. Todd
    Replies:
    1
    Views:
    502
    Martin Honnen
    May 12, 2004
  3. cvissy
    Replies:
    0
    Views:
    637
    cvissy
    Nov 16, 2004
  4. Mirror
    Replies:
    6
    Views:
    721
    Jason Cavett
    Apr 5, 2007
  5. al dav
    Replies:
    7
    Views:
    112
    Chris
    Jan 16, 2004
Loading...

Share This Page