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

Function test1

lib_acl/samples/xml/xml6/xml.c:516–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516static void test1(void)
517{
518 const char* data = "<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n"
519 "<?xml-stylesheet type=\"text/xsl\"\r\n"
520 "\thref=\"http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\"?>\r\n"
521 "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\r\n"
522 "\t\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\r\n"
523 " <!ENTITY xmllint \"<command>xmllint</command>\">\r\n"
524 "]>\r\n"
525 "<root name1 = \"value1\" name2 = \"val\\ue2\" name3 = \"v\\al'ue3\">hello world!</root>\r\n";
526 ACL_XML3 *xml;
527 ACL_XML3_NODE *node;
528 const char *encoding, *type, *href;
529 char *buf = acl_mystrdup(data);
530
531 xml = acl_xml3_alloc();
532
533 printf("---------------- xml data ----------------------------\r\n");
534
535 printf("%s\r\n", data);
536
537 printf("---------------- xml data end ------------------------\r\n");
538
539 acl_xml3_update(xml, buf);
540
541 printf("--------------- walk_xml_node ------------------------\r\n");
542
543 acl_myfree(buf);
544
545 walk_xml_node(xml->root, 0);
546
547 printf("--------------- walk_xml_node end --------------------\r\n");
548
549 printf("Enter any key to continue ...\r\n");
550 getchar();
551
552 printf("----------------- lookup meta data -------------------\r\n");
553 encoding = acl_xml3_getEncoding(xml);
554 type = acl_xml3_getType(xml);
555 node = acl_xml3_getElementMeta(xml, "xml-stylesheet");
556 if (node)
557 href = acl_xml3_getElementAttrVal(node, "href");
558 else
559 href = NULL;
560
561 printf("xml encoding: %s\r\n", encoding ? encoding : "null");
562 printf("xml type: %s\r\n", type ? type : "null");
563 printf("xml href: %s\r\n", href ? href : "null");
564
565 printf("----------------- lookup meta data end ---------------\r\n");
566
567 printf("Enter any key to continue ...\r\n");
568 getchar();
569 test_getElementsByTagName(xml, "root");
570
571 acl_xml3_free(xml);
572}
573

Callers 1

mainFunction · 0.70

Calls 9

acl_xml3_allocFunction · 0.85
acl_xml3_updateFunction · 0.85
acl_xml3_getEncodingFunction · 0.85
acl_xml3_getTypeFunction · 0.85
acl_xml3_getElementMetaFunction · 0.85
acl_xml3_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…