1

I am working in C++. I would like to ask how to obtain the value text from:

<message> text </message>

I have

TiXmlHandle handle(&doc);
TiXmlElement* section;
section=doc.FirstChildElement("message");

How to do it from now on? I know I have to work with .Element() but I don't know how.

Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
marryy
  • 215
  • 1
  • 6
  • 13

1 Answers1

1

You can use the function GetText() to obtain the contents of <message>. I put your XML-contents in a file called dummy.xml and used the following code to print the contents:

TiXmlDocument doc("dummy.xml");

if(doc.LoadFile())
{
    TiXmlHandle hDoc(&doc);
    TiXmlElement *pRoot;
    pRoot = doc.FirstChildElement("message");
    printf("pRoot text: %s", pRoot->GetText());

}
iceaway
  • 1,204
  • 1
  • 8
  • 12