xml
<?xml version="1.0" encoding="utf-8" ?> <ROOT> <COMPANY>Tencent</COMPANY> <STAFFS> <STAFF NAME = "clx"/> <STAFF NAME = "Jx"/> <STAFF NAME = "zhx"/> </STAFFS> </ROOT>
code
pugi::xml_document doc; pugi::xml_node root_node = doc.child("ROOT"); // get node by name std::string company = root_node .child("COMPANY").child_value(); for (pugi::xml_node node = _node.child("STAFFS").first_child(); node; node = node.next_sibling()) { std::string name = std::string(node.attribute("NAME").value()); printf("load %s ", name.c_str()); }