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

Function parse_xml

lib_acl/samples/xml/xml1/xml.c:184–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184static void parse_xml(int once, const char *data)
185{
186 ACL_XML *xml = acl_xml_alloc();
187 const char *ptr;
188 ACL_ITER iter1;
189 int i, total, left;
190 ACL_ARRAY *a;
191 ACL_XML_NODE *pnode;
192
193 ptr = data;
194
195 if (once) {
196 /* һ���Եط������� xml ���� */
197 ACL_METER_TIME("-------------once begin--------------");
198 acl_xml_parse(xml, ptr);
199 } else {
200 /* ÿ�ν�����һ���ֽ������� xml ���� */
201 ACL_METER_TIME("-------------stream begin--------------");
202 while (*ptr != 0) {
203 char ch2[2];
204
205 ch2[0] = *ptr;
206 ch2[1] = 0;
207 acl_xml_parse(xml, ch2);
208 ptr++;
209 }
210 }
211 ACL_METER_TIME("-------------end--------------");
212 printf("enter any key to continue ...\n");
213 getchar();
214
215 if (acl_xml_is_complete(xml, "root")) {
216 printf(">> Yes, the xml complete\n");
217 } else {
218 printf(">> No, the xml not complete\n");
219 }
220
221 total = xml->node_cnt;
222
223 /* ����������һ���ӽ�� */
224 acl_foreach(iter1, xml->root) {
225 ACL_ITER iter2;
226
227 ACL_XML_NODE *node = (ACL_XML_NODE*) iter1.data;
228 printf("tag> %s, text: %s\n", STR(node->ltag), STR(node->text));
229
230 /* ����һ���ӽ��Ķ����ӽ�� */
231 acl_foreach(iter2, node) {
232 ACL_ITER iter3;
233 ACL_XML_NODE *node2 = (ACL_XML_NODE*) iter2.data;
234
235 printf("\ttag> %s, text: %s\n", STR(node2->ltag), STR(node2->text));
236
237 /* ���������ӽ������� */
238 acl_foreach(iter3, node2->attr_list) {
239 ACL_XML_ATTR *attr = (ACL_XML_ATTR*) iter3.data;
240 printf("\t\tattr> %s: %s\n", STR(attr->name), STR(attr->value));
241 }

Callers 1

mainFunction · 0.70

Calls 11

acl_xml_allocFunction · 0.85
acl_xml_is_completeFunction · 0.85
acl_xml_free_arrayFunction · 0.85
acl_xml_getElementByIdFunction · 0.85
acl_xml_node_nextFunction · 0.85
acl_xml_node_deleteFunction · 0.85
acl_xml_freeFunction · 0.85
build_xmlFunction · 0.70
acl_foreachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…