| 6 | using namespace std; |
| 7 | |
| 8 | static void test() |
| 9 | { |
| 10 | acl::string buf; |
| 11 | acl::xml1 xml; |
| 12 | acl::xml_node& root = xml.get_root(); |
| 13 | acl::xml_node& server = xml.create_node("server"); |
| 14 | root.add_child(server); |
| 15 | |
| 16 | acl::xml_node& proc1 = xml.create_node("proc"); |
| 17 | server.add_child(proc1); |
| 18 | proc1.add_child("pid", false, "1111"); |
| 19 | proc1.add_child("conns", false, "111"); |
| 20 | proc1.add_child("load", false, "0.5"); |
| 21 | |
| 22 | acl::xml_node& proc2 = xml.create_node("proc"); |
| 23 | server.add_child(proc2); |
| 24 | proc2.add_child("pid", false, "2111"); |
| 25 | proc2.add_child("conns", false, "211"); |
| 26 | proc2.add_child("load", false, "2.5"); |
| 27 | |
| 28 | printf("-------------- after build_xml -------------------\r\n"); |
| 29 | xml.build_xml(buf); |
| 30 | printf("%s\r\n", buf.c_str()); |
| 31 | |
| 32 | printf("Enter any key to continue ...\r\n"); |
| 33 | getchar(); |
| 34 | |
| 35 | proc1.detach(); |
| 36 | printf("--------------- after detach proc1 --------------\r\n"); |
| 37 | size_t len; |
| 38 | printf("%s\r\n", xml.to_string(&len)); |
| 39 | |
| 40 | printf("Enter any key to continue ...\r\n"); |
| 41 | getchar(); |
| 42 | |
| 43 | proc2.detach(); |
| 44 | printf("--------------- after detach proc2 --------------\r\n"); |
| 45 | printf("%s\r\n", xml.to_string(&len)); |
| 46 | |
| 47 | printf("Enter any key to continue ...\r\n"); |
| 48 | getchar(); |
| 49 | } |
| 50 | |
| 51 | static void print_attrs(acl::xml_node& node) |
| 52 | { |