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

Method do_xml

lib_acl_cpp/samples/http_response/main.cpp:105–141  ·  view source on GitHub ↗

���� text/xml ������

Source from the content-addressed store, hash-verified

103
104 // ���� text/xml ������
105 bool do_xml(http_response& res, const char* req_charset, string& err) {
106 xml1 body;
107 if (res.get_body(body, local_charset_) == false) {
108 err += "get_body error";
109 return false;
110 }
111 xml_node* node = body.first_node();
112 while (node) {
113 const char* tag = node->tag_name();
114 const char* name = node->attr_value("name");
115 const char* pass = node->attr_value("pass");
116 printf(">>tag: %s, name: %s, pass: %s\r\n",
117 tag ? tag : "null",
118 name ? name : "null",
119 pass ? pass : "null");
120 node = body.next_node();
121 }
122
123 // ������Ӧͷ�ֶ�
124 http_header& header = res.response_header();
125 string ctype("text/xml");
126 if (req_charset) {
127 ctype << "; charset=" << req_charset;
128 header.set_content_type(ctype);
129 } else {
130 header.set_content_type(ctype);
131 }
132
133 printf(">>ctype: %s\r\n", ctype.c_str());
134
135 // ������Ӧ�����ݣ���������Ӧ������
136 string buf;
137 body.build_xml(buf);
138
139 // ������Ӧ������
140 return response_body(res, buf, req_charset);
141 }
142
143 // ���� text/json ����
144 bool do_json(http_response& res, const char* req_charset, string& err) {

Callers

nothing calls this directly

Calls 8

set_content_typeMethod · 0.80
get_bodyMethod · 0.45
first_nodeMethod · 0.45
tag_nameMethod · 0.45
attr_valueMethod · 0.45
next_nodeMethod · 0.45
c_strMethod · 0.45
build_xmlMethod · 0.45

Tested by

no test coverage detected