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

Function parse_xml

lib_acl/samples/xml/xml2/main.c:411–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411static void parse_xml(int once, const char *data,
412 const char* root, int multi_root)
413{
414 ACL_XML *xml = get_xml(once, data, root, multi_root);
415 ACL_XML_NODE *node;
416 int total = xml->node_cnt, left;
417
418 /* �������� xml �ڵ� */
419 walk_xml(xml);
420
421 /* �ݹ���� root �ڵ�������ӽڵ� */
422 printf("-------------------- walk root node -------------------\r\n");
423 walk_xml_node(xml->root, 0);
424 printf("-------------------- walk root node end ---------------\r\n");
425
426 printf("Enter any key to continue ...\r\n");
427 getchar();
428
429 /* ���ݱ�ǩ����� xml ��㼯�� */
430
431 /* ��ѯ������Ϊ name, ����ֵΪ user ������ xml ���ļ��� */
432 test_getElementsByTagName(xml, "user");
433
434 /* ��ѯ������Ϊ name, ����ֵΪ user2_1 ������ xml ���ļ��� */
435 test_getElementsByTagName(xml, "user2_1");
436
437 /* ��ѯ������Ϊ id, ����ֵΪ id2_2 ������ xml ��㼯�� */
438 (void) test_getElementById(xml, "id2_2");
439
440 /* ��ѯ������Ϊ id, ����ֵΪ id2_3 ������ xml ��㼯�� */
441 node = test_getElementById(xml, "id2_3");
442 if (node) {
443 int ndel = 0, node_cnt;
444
445 /* ɾ���ý�㼰���ӽ�� */
446 printf(">>>before delete %s, total: %d\n",
447 STR(node->ltag), xml->node_cnt);
448 ndel = acl_xml_node_delete(node);
449 node_cnt = xml->node_cnt;
450 printf(">>>after delete id2_3(%d deleted), total: %d\n",
451 ndel, node_cnt);
452 }
453 node = test_getElementById(xml, "id2_3");
454
455 list_xml_tags(xml);
456
457 /* �ͷ� xml ���� */
458 left = acl_xml_free(xml);
459
460 printf("Free all node ok, total(%d), left is: %d\n", total, left);
461 printf("Enter any key to continue ...\r\n");
462 getchar();
463}
464
465static int parse_xml_file(const char *filepath)
466{

Callers 1

mainFunction · 0.70

Calls 8

acl_xml_node_deleteFunction · 0.85
acl_xml_freeFunction · 0.85
get_xmlFunction · 0.70
walk_xmlFunction · 0.70
walk_xml_nodeFunction · 0.70
test_getElementByIdFunction · 0.70
list_xml_tagsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…