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

Function parse_xml

lib_acl/samples/xml/xml3/xml.c:500–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500static void parse_xml(int once, const char *data,
501 const char* root, int multi_root)
502{
503 ACL_XML2 *xml = get_xml(once, data, root, multi_root);
504 ACL_XML2_NODE *node;
505 int total = xml->node_cnt, left;
506 const char *ptr;
507
508 /* �������� xml �ڵ� */
509 walk_xml(xml);
510
511 /* �ݹ���� root �ڵ�������ӽڵ� */
512 printf("-------------------- walk root node -------------------\r\n");
513 walk_xml_node(xml->root, 0);
514 printf("-------------------- walk root node end ---------------\r\n");
515
516 printf("Enter any key to continue ...\r\n");
517 getchar();
518
519 /* ���ݱ�ǩ����� xml ��㼯�� */
520
521 /* ��ѯ������Ϊ name, ����ֵΪ user ������ xml ���ļ��� */
522 test_getElementsByTagName(xml, "user");
523
524 /* ��ѯ������Ϊ name, ����ֵΪ user2_1 ������ xml ���ļ��� */
525 test_getElementsByTagName(xml, "user2_1");
526
527 /* ��ѯ������Ϊ id, ����ֵΪ id2_2 ������ xml ��㼯�� */
528 (void) test_getElementById(xml, "id2_2");
529
530 /* ��ѯ������Ϊ id, ����ֵΪ id2_3 ������ xml ��㼯�� */
531 node = test_getElementById(xml, "id2_3");
532 if (node) {
533 int ndel = 0, node_cnt;
534
535 /* ɾ���ý�㼰���ӽ�� */
536 printf(">>>before delete %s, total: %d\n",
537 node->ltag, xml->node_cnt);
538 ndel = acl_xml2_node_delete(node);
539 node_cnt = xml->node_cnt;
540 printf(">>>after delete id2_3(%d deleted), total: %d\n",
541 ndel, node_cnt);
542 }
543 node = test_getElementById(xml, "id2_3");
544
545 list_xml_tags(xml);
546
547 printf("----------------- build xml -------------------------\r\n");
548 ptr = acl_xml2_build(xml);
549 printf("%s, len: %ld, %ld\r\n", ptr, (long) strlen(ptr),
550 (long) (acl_vstring_end(xml->vbuf) - ptr));
551 if (strlen(ptr) != (size_t) (acl_vstring_end(xml->vbuf) - ptr)) {
552 printf("%s(%d): invalid xml size: %ld, %ld\r\n", __FUNCTION__,
553 __LINE__, (long) strlen(ptr),
554 (long) (acl_vstring_end(xml->vbuf) - ptr));
555 assert(0);
556 }
557

Callers 1

mainFunction · 0.70

Calls 10

acl_xml2_node_deleteFunction · 0.85
acl_xml2_buildFunction · 0.85
acl_vstring_freeFunction · 0.85
acl_xml2_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…