| 409 | } |
| 410 | |
| 411 | static 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 | |
| 465 | static int parse_xml_file(const char *filepath) |
| 466 | { |
no test coverage detected
searching dependent graphs…