source: icGREP/icgrep-devel/icgrep/combine/pugixml/docs/samples/xpath_variables.cpp @ 5516

Last change on this file since 5516 was 5516, checked in by faldebey, 21 months ago

added combinatorial testing tool

File size: 1.1 KB
Line 
1#include "pugixml.hpp"
2
3#include <iostream>
4#include <string>
5
6int main()
7{
8    pugi::xml_document doc;
9    if (!doc.load_file("xgconsole.xml")) return -1;
10
11// tag::code[]
12    // Select nodes via compiled query
13    pugi::xpath_variable_set vars;
14    vars.add("remote", pugi::xpath_type_boolean);
15
16    pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
17
18    vars.set("remote", true);
19    pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc);
20
21    vars.set("remote", false);
22    pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc);
23
24    std::cout << "Remote tool: ";
25    tools_remote[2].node().print(std::cout);
26
27    std::cout << "Local tool: ";
28    tools_local[0].node().print(std::cout);
29
30    // You can pass the context directly to select_nodes/select_node
31    pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
32
33    std::cout << "Local tool imm: ";
34    tools_local_imm[0].node().print(std::cout);
35// end::code[]
36}
37
38// vim:et
Note: See TracBrowser for help on using the repository browser.