#include#include int main() { tinyxml2::XMLDocument doc; doc.LoadFile("example.xml"); tinyxml2::XMLElement* root = doc.FirstChildElement("root"); const char* value = root->Value(); std::cout << "The value of the root element is: " << value << std::endl; return 0; }
#includeIn this example, we load an XML file `"example.xml"`, then retrieve the root element using `FirstChildElement("root")`. We then change the value of the root element to `"new_root_value"` using `SetValue()` function. Finally, we display the new value of the root element using `Value()` function. The TinyXML-2 library package provides several other functions to access and manipulate TiXmlElement Value.#include int main() { tinyxml2::XMLDocument doc; doc.LoadFile("example.xml"); tinyxml2::XMLElement* root = doc.FirstChildElement("root"); root->SetValue("new_root_value"); std::cout << "The new value of the root element is: " << root->Value() << std::endl; return 0; }