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

Function test

lib_acl_cpp/samples/xml/xml1/xml.cpp:8–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace std;
7
8static void test(void)
9{
10 const char *data =
11 "<?xml version=\"1.0\"?>\r\n"
12 "<?xml-stylesheet type=\"text/xsl\"\r\n"
13 " href=\"http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\"?>\r\n"
14 "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\r\n"
15 " \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\r\n"
16 " <!ENTITY xmllint \"<command>xmllint</command>\">\r\n"
17 "]>\r\n"
18 "<root>test\r\n"
19 " <!-- <edition> - <!--0.5--> - </edition> -->\r\n"
20 " <user name = user_name>zsx\r\n"
21 " <age>38</age>\r\n"
22 " </user>\r\n"
23 "</root>\r\n"
24 "<!-- <edition><!-- 0.5 --></edition> -->\r\n"
25 "<!-- <edition>0.5</edition> -->\r\n"
26 "<!-- <edition> -- 0.5 -- </edition> -->\r\n"
27 "<root name='root' id='root_id'>test</root>\r\n";
28 acl::xml1 xml;
29
30#if 1
31 const char* p = data;
32 char tmp[2];
33 while (*p)
34 {
35 tmp[0] = *p++;
36 tmp[1] = 0;
37 xml.update(tmp);
38 }
39#else
40 xml.update(data);
41#endif
42
43 const vector<acl::xml_node*>& elements = xml.getElementsByTagName("user");
44
45 if (!elements.empty()) {
46 vector<acl::xml_node*>::const_iterator cit = elements.begin();
47 for (; cit != elements.end(); cit++) {
48 acl::xml_node *node = *cit;
49 printf("tagname: %s, text: %s\n", node->tag_name() ? node->tag_name() : "",
50 node->text() ? node->text() : "");
51
52 const acl::xml_attr* attr = (*cit)->first_attr();
53 while (attr)
54 {
55 printf("test1: %s=%s\r\n", attr->get_name(), attr->get_value());
56 attr = (*cit)->next_attr();
57 }
58 }
59 }
60
61 xml.reset();
62
63 //////////////////////////////////////////////////////////////////////
64
65 const char* s2 = "<html><head>Title\r\n</head><body>��λͬѧ��\r\n"

Callers 1

mainFunction · 0.70

Calls 15

beginMethod · 0.80
set_textMethod · 0.80
get_parentMethod · 0.80
updateMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
tag_nameMethod · 0.45
textMethod · 0.45
first_attrMethod · 0.45
get_nameMethod · 0.45
get_valueMethod · 0.45
next_attrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…