// Load XML file pugi::xml_document doc; doc.load_file("books.xml"); // Get book node pugi::xml_node book_node = doc.child("book"); // Get author attribute std::string author_name = book_node.attribute("author").value(); // Print author name std::cout << "Author: " << author_name << std::endl;
// Create new person node pugi::xml_node person_node = doc.append_child("person"); // Set attributes person_node.append_attribute("name") = "John Doe"; person_node.append_attribute("age") = 25;In both examples, the pugi library is used to load, parse, and modify an XML document.