Menu

Loading xml file from another directory

2006-03-23
2013-05-20
  • AllWrightNow

    AllWrightNow - 2006-03-23

    I am using Borland C++Builder 5.0 on WindowsXP.
    I have a directory structure that includes separate directories for different files:
    \exe - executables
    \src - source files
    \tinyxml - tinyxml files
    \trial - any *.xml files

    I declare a Sting and enter the file name incluing the path for the "xml" file then pass it to LoadFile() as shown below.

    void TXMLEquipmentDocument::Open(String TheDocument)
    {
      const char *FileName;

      FileName =  TheDocument.c_str();
      TiXmlDocument doc(FileName);
      LoadOK = doc.LoadFile();
      if (LoadOK)
       {
          ..................
       }
      else
       {
         ...................
       }
    }

    The tinyxml.cpp function "LoadFile( const char* filename, TiXmlEncoding encoding )" fails to open the file (line 1017) appearing not to recognise the filename with the associated path.  If I open an "xml" file located in the "\exe" directory everything works ok.

    Can you offer me a solution that allows me to use separate directory locations?

    Regards  Tony

     
    • Yves Berquin

      Yves Berquin - 2006-03-23

      I guess you have an error in the path you use. Are you sure you double the backslashes ("..\\trial\\tr1.xml") in your case?
      I am often using full path to files, and never had any problem with TinyXML in that area.

       
    • AllWrightNow

      AllWrightNow - 2006-03-23

      Yves

      Thanks for your quick reply and yes the double backslashes ("...\\trial\\myfile.xml") are in place.  I also recompiled my program after setting one of the first lines of tinyxml.h to "#define TINYXML_USE_STL".  Are there any other options that need to be set?  Are there any Borland specific issues?

      Regards Tony

       
    • David Jorge

      David Jorge - 2006-03-28

      Have you debug your program to see what is the value of FileName?
      I have never had problems and load xml files from different locations also.

       
    • dcoy

      dcoy - 2007-02-15

      I guess it could be that the Working Directory is not set, and it might not default to the \exe dir.
      I've had a similar problem in VS6 and setting the Working Directory for the executable to the same dir as the executable solved it for me.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.