0

I am trying to include the TinyXml library to my Visual Studio C++ project with no success.

I have downloaded the library folder with the .h and .cpp files and tried all kind of adding... it doesn't help...

I found this tutorial, and did as it told.

It still does not recognize #include "xmlEffect.h"

Any suggestions most welcome.

Albert Xing
  • 5,620
  • 3
  • 21
  • 40
  • 1
    Can you be more specific about "all kind of adding"? Where is the tinyxml code relative to your other source code? What settings did you try changing? What did you add to them? – simonc Aug 15 '13 at 18:04

2 Answers2

2

Take a look again at Step Four.

Step Four

Copy the following files to your project folder

  • tinystr.h
  • tinyxml.h
  • tinyxmlparser.cpp
  • tinystr.cpp
  • tinyxml.cpp
  • tinyxmlerror.cpp

from solution explorer add these file to your project as (Add >> Existing Item)

Update:

If your projects structure is like this:

   Project
      |-- Debug
      |-- src
      |
      |-- inc
      |    |
      |    +-- xmlEffect.h
      |
      +-- main.cpp

Then #include "inc/xmlEffect.h"instead of #include "xmlEffect.h"

gifnoc-gkp
  • 1,506
  • 1
  • 8
  • 17
  • i did all that, i've add a new c++ project. in Header files folder i have : tinystr.h and tinyxml.h in source files folder i have : tinystr.cpp , tinyxml.cpp , tinyxmlerror.cpp , tinyxmlparser.cpp also i have my new file i called it example.cpp. and its still not working... – Michael Yudchak Aug 15 '13 at 19:08
  • @MichaelYudchak Check again. – gifnoc-gkp Aug 15 '13 at 19:12
  • IntelliSense: identifier "xmlSetting" is undefined IntelliSense: identifier "getchar" is undefined IntelliSense: cannot open source file "xmlEffect.h" 1 parse Cannot open include file: 'xmlEffect.h': No such file or directory – Michael Yudchak Aug 15 '13 at 20:06
2

I think Michael Yudchak's downvote a little unfair. His written English could have been better but his question I think was still valid.

The example usage given by Step 5 of the tutorial gives an example of using "xmlEffect.h" without explaining where it comes from or what it is:

#include "xmlEffect.h"  

int main(void)
{
    char c;

    xmlSetting xmlset;

    xmlset.saveEffectXML("test.xml","child1","child2","3000","4000");

    xmlset.loadEffectXML("test.xml");   


     c=getchar();
}

The solution therefore is to follow the first four steps, as it says, but ignore Step 5 and just try out an example of your own. Example minimalist "Hello World" example:

Example XML: test.xml

<?xml version="1.0" ?>
<Hello>World</Hello>

Example code: main.cpp

#include "tinyxml.h"
#include <string>

int main()
{   
    TiXmlDocument doc( "test.xml" );

    if ( doc.LoadFile() )
    {   
        TiXmlElement* element = doc.FirstChildElement( "Hello" );   
        std::string text = element->GetText();
    }

    return 0;
}
AndyUK
  • 3,933
  • 7
  • 42
  • 44