pugi::xml_document doc; pugi::xml_node root = doc.append_child("root"); pugi::xml_node child = root.append_child("child"); child.append_child(pugi::node_pcdata).set_value("Hello World!");
pugi::xml_document doc; pugi::xml_node root = doc.append_child("root"); pugi::xml_node child = root.append_child("child"); child.append_attribute("id").set_value(123);This code creates a new XML document with a root element and a child element. Then, it adds a new attribute with the "id" name and the 123 value to the child element. The package library used in these examples is the Pugi XML C++ library. It is a lightweight and fast XML parser for C++.