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

Function parse_xml

lib_acl/samples/xml/xml6/xml.c:462–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462static void parse_xml(const char *data, const char* root, int multi_root)
463{
464 char *buf = acl_mystrdup(data);
465 ACL_XML3 *xml = get_xml(buf, root, multi_root);
466 ACL_XML3_NODE *node;
467 int total = xml->node_cnt, left;
468
469 /* �������� xml �ڵ� */
470 walk_xml(xml);
471
472 /* �ݹ���� root �ڵ�������ӽڵ� */
473 printf("-------------------- walk root node -------------------\r\n");
474 walk_xml_node(xml->root, 0);
475 printf("-------------------- walk root node end ---------------\r\n");
476
477 printf("Enter any key to continue ...\r\n");
478 getchar();
479
480 /* ���ݱ�ǩ����� xml ��㼯�� */
481
482 /* ��ѯ������Ϊ name, ����ֵΪ user ������ xml ���ļ��� */
483 test_getElementsByTagName(xml, "user");
484
485 /* ��ѯ������Ϊ name, ����ֵΪ user2_1 ������ xml ���ļ��� */
486 test_getElementsByTagName(xml, "user2_1");
487
488 /* ��ѯ������Ϊ id, ����ֵΪ id2_2 ������ xml ��㼯�� */
489 (void) test_getElementById(xml, "id2_2");
490
491 /* ��ѯ������Ϊ id, ����ֵΪ id2_3 ������ xml ��㼯�� */
492 node = test_getElementById(xml, "id2_3");
493 if (node) {
494 int ndel = 0, node_cnt;
495
496 /* ɾ���ý�㼰���ӽ�� */
497 printf(">>>before delete %s, total: %d\n",
498 node->ltag, xml->node_cnt);
499 ndel = acl_xml3_node_delete(node);
500 node_cnt = xml->node_cnt;
501 printf(">>>after delete id2_3(%d deleted), total: %d\n",
502 ndel, node_cnt);
503 }
504 node = test_getElementById(xml, "id2_3");
505
506 list_xml_tags(xml);
507
508 /* �ͷ� xml ���� */
509 left = acl_xml3_free(xml);
510
511 acl_myfree(buf);
512
513 printf("Free all node ok, total(%d), left is: %d\n", total, left);
514}
515
516static void test1(void)
517{

Callers 1

mainFunction · 0.70

Calls 8

acl_xml3_node_deleteFunction · 0.85
acl_xml3_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…