MCPcopy Create free account
hub / github.com/acl-dev/acl / test2

Function test2

lib_acl_cpp/samples/xml/xml2/xml.cpp:65–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65static 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
116static void test3()
117{

Callers 1

mainFunction · 0.70

Calls 10

print_attrsFunction · 0.85
get_parentMethod · 0.80
build_xmlMethod · 0.45
c_strMethod · 0.45
resetMethod · 0.45
updateMethod · 0.45
first_nodeMethod · 0.45
textMethod · 0.45
tag_nameMethod · 0.45
next_nodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…