TiXmlDocument doc("example.xml"); // create a document object and load an XML file TiXmlNode* root = doc.FirstChild("root"); // get the root node of the document TiXmlElement* element = root->FirstChildElement("element"); // get the first "element" node under the root const char* text = element->GetText(); // get the text content of the "element"
TiXmlElement* element = new TiXmlElement("book"); // create a new "book" element element->SetAttribute("ID", "123"); // set an attribute for the element TiXmlText* title = new TiXmlText("Harry Potter"); // create a new text node element->LinkEndChild(title); // add the text node as a child of the elementIn this example, we create a new `TiXmlElement` object called "book" and set an attribute for it. Then we create a new `TiXmlText` object with the book title and add it as a child of the "book" element using the `LinkEndChild()` function. The package library for TinyXML is usually called "libtinyxml-dev" on Linux systems, and it can be installed using a package manager like apt-get or yum.