Menu

What is going on with my file

Developer
Anonymous
2008-11-23
2013-05-20
  • Anonymous

    Anonymous - 2008-11-23

    I have the following code:

    TiXmlDocument document("text.xml");
    bool success = document.LoadFile();
    if(not success) cout << "no";

    and it prints always "no"

    Whats the problem, TinyXML cant read my file!!

     
    • Ellers

      Ellers - 2008-11-24

      I'm guessing this is Windows with MSVC (next time, mention this in your post).
      I'm guessing you didn't mean literally "not" because that won't compile.

      And it would be easier if you did
        cout << "success="<<success<<endl;

      Anyway, chances are you're running your executable from a different directory than where your file is.

      Options:
      - put the full path of the file in the string (e.g. move to c:\whatever.xml)
      - edit the options in studio and tell it exactly where to run from (its probably running from the Debug dir)
      - run it from a dos shell so you have full control

      HTH
      Ellers

       
      • Anonymous

        Anonymous - 2008-11-24

        I am using Dev-C++ with MingW and yes I wrote "not" litterally and works.

        The executable is in the same place as the file, and writing the full path doesnt works.

         
        • Ellers

          Ellers - 2008-11-24

          Fair enough. I guess "not" is #ifdef'd to "!" in your code base.

          Still, just in case "not" isn't defined correctly, why not use the following instead and you'll remove any chance of it being wrong?:

            cout << "success="<<success<<endl;

          I thought there was an error code or message set somewhere - I don't have the src handy, but have a look and see.

          Failing that, step through it in the debugger.

          And otherwise, post the contents of the xml file; perhaps it really isn't valid.

           
    • Anonymous

      Anonymous - 2008-11-24

      Anyway, you can give me some directions to extract de type attribute and the content of "Contenido"?

      <?xml version='1.0' encoding='iso-8859-1'?>
      <transmision>
      <msg type='nombre'><contenido>Jualin</contenido></msg>
      </transmision>

      Thanks for the help.

       

Log in to post a comment.