TiXmlDocument doc("example.xml"); doc.LoadFile(); TiXmlNode* root = doc.FirstChild("root"); for (TiXmlNode* node = root->FirstChild(); node != NULL; node = node->NextSibling()) { // Do something with child element }
TiXmlDocument doc("example.xml"); doc.LoadFile(); TiXmlElement* root = doc.FirstChildElement("root"); TiXmlElement* child = root->FirstChildElement("child"); const char* text = child->GetText(); // Access the text value of the first child elementBoth examples use TinyXML library to parse and manipulate XML data, and illustrate the use of the FirstChild method to access the first child element of an XML element.