TiXmlAttribute* attribute = element->FirstAttribute(); while(attribute) { std::cout << attribute->Name() << " = " << attribute->Value() << std::endl; attribute = attribute->Next(); }
TiXmlAttribute* attribute = element->FindAttribute("id"); if (attribute) { int id = attribute->IntValue(); std::cout << "id = " << id << std::endl; }This code finds the "id" attribute of an XML element and prints its integer value. The TinyXML-2 library is a small, lightweight XML parser for C++. It is designed to be simple and easy to use, while still providing powerful functionality. It is useful for applications that need to parse and manipulate XML data, such as configuration files, data exchange, and database interfaces.