tinyXML and "getText"

A forum to store posts deemed exceptionally wise and useful
Post Reply
wolfsb
Posts: 26
Joined: Sun Dec 26, 2004 1:51 pm
Location: Berlin, Germany

tinyXML and "getText"

Post by wolfsb »

Actually I was about to post and ask a question how I could be done. Then I was able to solve the problem myself. Here is the result, just in case someone runs into the same problem and is looking for a solution.

tinyXML doesn't have a "getText" method. If you need to print the content "blablabla" (and not the tagname) out of a construct like the following in order to use it with <addMessageBox> or <addStaticText>

<planets>
<venus>blablablabla</venus>
</planets>

here is something that works (at least it does work for me):

stringw topic = L"Solarsystem";

TiXmlDocument doc("../tut_media/xml/solsys.xml");
TiXmlHandle handle(&doc);

TiXmlText* text = handle.ChildElement("planets", 0).ChildElement("venus", 0).FirstChild().Text();
if(text)
{
const char* message = text->Value();
stringw msg(message);
msg.c_str();
device->getGUIEnvironment()->addMessageBox(topic.c_str(), msg.c_str());
}

maybe someone finds this useful

wolfsb, berlin, Germany
Post Reply