CXBMCTinyXML::XMLDocument doc; CXBMCTinyXML::ErrorDesc err; if (doc.LoadFile("config.xml", &err)) { // file loaded successfully } else { std::cout << "Error: " << err.GetDescription() << std::endl; }
CXBMCTinyXML::XMLElement* root = doc.FirstChildElement("root"); CXBMCTinyXML::ErrorDesc err; if (root == nullptr) { std::cout << "Error: " << err.SetError("root element not found") << std::endl; }In this example, we try to get the first child element of the XML document with the tag name "root". If there is no such element, we create an ErrorDesc object and call its SetError() method to set the error description. We then print the error description to the console. The CXBMCTinyXML library is a package library that provides a C++ wrapper for TinyXML.