#include static constexpr char kXmlA[] = R"( hello text1 text2 text3 )"; static constexpr char kXmlB[] = R"( text1 text2 text3 )"; TEST_SUITE("pugixml") { TEST_CASE("xpath query") { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_string(kXmlA); CHECK(result); pugi::xpath_node_set nodes = doc.select_nodes("//node"); CHECK_EQ(nodes.size(), 3); CHECK_EQ(nodes[0].node().attribute("id").as_int(), 1); CHECK_EQ(nodes[1].node().attribute("id").as_int(), 2); CHECK_EQ(nodes[2].node().attribute("id").as_int(), 3); } TEST_CASE("xpath *") { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_string(kXmlA); CHECK(result); pugi::xpath_node_set nodes = doc.select_nodes("/*/str"); CHECK(nodes.size() == 1); CHECK_EQ(std::string("hello"), nodes[0].node().text().as_string()); } }