I currently have an XML file which I'm parsing using TinyXML. The top of my XML file look as so :
<Classroom>12
<ClassName>name</ClassName>
...
</Classroom>
I'm attempting to access the text in ClassName. I am currently getting a segmentation fault using this:
TiXmlDocument doc;
doc.LoadFile(file);
TiXmlHandle handle(&doc);
TiXmlElement * child = handle.FirstChild().FirstChild().ToElement();
cout<<child->GetText();
What am I doing wrong?
Thanks!
<Classroom>
You can change your code to the following:
TiXmlElement * child = handle.FirstChild("Classroom").FirstChild("ClassName").ToElement();