| 63 | } |
| 64 | |
| 65 | static void test2() |
| 66 | { |
| 67 | acl::xml1 xml; |
| 68 | acl::xml_node& root = xml.get_root(); |
| 69 | root.add_child("users", true) |
| 70 | .add_child("user", true) |
| 71 | .add_attr("account", "\"zsxxsz\" <zsxxsz@263.net>") |
| 72 | .add_attr("sex", "<male>") |
| 73 | .add_attr("addr", "\"Beijing\"") |
| 74 | .add_attr("nick", "<xsz@sina.com>") |
| 75 | .add_child("name", false, "zsxxsz") |
| 76 | .add_child("email", false, "\'zsxxsz\' <zsxxsz@263.net>") |
| 77 | .add_child("sex", false, "male") |
| 78 | .get_parent() |
| 79 | .add_child("user", true) |
| 80 | .add_attr("account", "\"zsxxsz\" <zsxxsz@263.net>") |
| 81 | .add_attr("sex", "<male>") |
| 82 | .add_attr("addr", "\"&Beijing&\"") |
| 83 | .add_attr("nick", "<xsz@sina.com>") |
| 84 | .add_child("name", false, "zsx1") |
| 85 | .add_child("email", false, "\"zsx1\" <zsx1@263.net>") |
| 86 | .add_child("age", false, "22"); |
| 87 | |
| 88 | acl::string buf; |
| 89 | xml.build_xml(buf); |
| 90 | printf("%s\r\n", buf.c_str()); |
| 91 | |
| 92 | xml.reset(); |
| 93 | xml.xml_decode(true); |
| 94 | |
| 95 | const char* p = buf.c_str(); |
| 96 | char tmp[2]; |
| 97 | while (*p) |
| 98 | { |
| 99 | tmp[0] = *p; |
| 100 | tmp[1] = 0; |
| 101 | xml.update(tmp); |
| 102 | ++p; |
| 103 | } |
| 104 | |
| 105 | acl::xml_node* iter = xml.first_node(); |
| 106 | while (iter) |
| 107 | { |
| 108 | const char* txt = iter->text(); |
| 109 | printf("tag: %s; txt: %s", iter->tag_name(), txt ? txt : "null"); |
| 110 | print_attrs(*iter); |
| 111 | printf("\r\n"); |
| 112 | iter = xml.next_node(); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | static void test3() |
| 117 | { |
no test coverage detected
searching dependent graphs…