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

Function test1

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

Source from the content-addressed store, hash-verified

500}
501
502static void test1(void)
503{
504 const char* data = "<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n"
505 "<?xml-stylesheet type=\"text/xsl\"\r\n"
506 "\thref=\"http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\"?>\r\n"
507 "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\r\n"
508 "\t\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\r\n"
509 " <!ENTITY xmllint \"<command>xmllint</command>\">\r\n"
510 "]>\r\n"
511 "<root name1 = \"value1\" name2 = \"val\\ue2\" name3 = \"v\\al'ue3\">hello world!</root>\r\n";
512 ACL_XML *xml;
513 ACL_XML_NODE *node;
514 const char *encoding, *type, *href;
515
516 xml = acl_xml_alloc();
517
518 printf("------------------------------------------------------\r\n");
519
520 printf("%s\r\n", data);
521
522 acl_xml_update(xml, data);
523
524 printf("--------------- walk_xml_node ------------------------\r\n");
525
526 walk_xml_node(xml->root, 0);
527
528 printf("--------------- walk_xml_node end --------------------\r\n");
529
530 printf("Enter any key to continue ...\r\n");
531 getchar();
532
533 printf("----------------- lookup meta data -------------------\r\n");
534 encoding = acl_xml_getEncoding(xml);
535 type = acl_xml_getType(xml);
536 node = acl_xml_getElementMeta(xml, "xml-stylesheet");
537 if (node)
538 href = acl_xml_getElementAttrVal(node, "href");
539 else
540 href = NULL;
541
542 printf("xml encoding: %s\r\n", encoding ? encoding : "null");
543 printf("xml type: %s\r\n", type ? type : "null");
544 printf("xml href: %s\r\n", href ? href : "null");
545
546 printf("----------------- lookup meta data end ---------------\r\n");
547
548 printf("Enter any key to continue ...\r\n");
549 getchar();
550 test_getElementsByTagName(xml, "root");
551
552 acl_xml_free(xml);
553}
554
555static void usage(const char *procname)
556{

Callers 1

mainFunction · 0.70

Calls 9

acl_xml_allocFunction · 0.85
acl_xml_updateFunction · 0.85
acl_xml_getEncodingFunction · 0.85
acl_xml_getTypeFunction · 0.85
acl_xml_getElementMetaFunction · 0.85
acl_xml_freeFunction · 0.85
walk_xml_nodeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…