#include "tinyxml2.h" using namespace tinyxml2; int main() { XMLDocument doc; doc.LoadFile("people.xml"); XMLElement* person = doc.FirstChildElement("people")->FirstChildElement("person"); const char* name = person->Attribute("name"); return 0; }
#includePackage Library: The first example uses the "tinyxml2" library, while the second example uses the "pugixml" library.#include "pugixml.hpp" using namespace std; using namespace pugi; int main() { xml_document doc; doc.load_file("books.xml"); xml_node books = doc.child("books"); xml_node book = books.find_child_by_attribute("book", "id", "123"); const char* id = book.attribute("id").value(); cout << "ID: " << id << endl; return 0; }