1

I am new to tinyXml2. I am trying to parse an xml file and print the text in the root tag. this is my code.

#include<stdio.h>
#include "tinyxml2.h"

using namespace std;

int main()
{
    XMLDocument doc;
    doc.LoadFile("input.xml");
    const char *title = doc.FirstChildElement("root")->GetText();
    printf("%s\n", title);
    return 0;
}

On building this I get an error saying XMLDocument was not declared in this scope.

What is the problem?

mpromonet
  • 11,326
  • 43
  • 62
  • 91
user1926586
  • 11
  • 1
  • 2
  • How the contents of the XML file is relevant to the compiler error? –  Dec 24 '12 at 12:18

1 Answers1

12

You have to specify the namespace. Either add

using namespace tinyxml2;

to the beginning of your code, after the #include directives, or explicitly specify it when you declare doc:

tinyxml2::XMLDocument doc;

etc.