5 #define ROOTNODE "/Configuration/output/menu"
6 #define LEAFNODE "name"
7 #define PATH ROOTNODE"/"LEAFNODE
13 root_id = xmlOpen("sample.xml");
16 void *path_id, *node_id;
19 printf("\nTesting xmlNodeGetString for /Configuration/output/test:\t\t");
20 s = xmlNodeGetString(root_id , "/Configuration/output/test");
23 printf("failed.\n\t'%s' should be empty\n", s);
29 printf("Testing xmlGetString for Configuration/output/test:\t\t\t");
30 path_id = xmlNodeGet(root_id, "*/*/test");
33 s = xmlGetString(path_id);
36 printf("failed.\n\t'%s' should be empty\n", s);
43 path_id = xmlNodeGet(root_id, PATH);
44 node_id = xmlNodeGet(root_id, ROOTNODE);
46 if (path_id && node_id)
51 xmlCopyString(path_id, buf, BUFLEN);
53 printf("Testing xmlNodeCopyString against xmlGetString:\t\t\t\t");
54 if ((s = xmlGetString(path_id)) != 0)
56 if (strcmp(s, buf)) /* not the same */
57 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
61 printf("Testing xmlCopyString against xmlGetString:\t\t\t\t");
62 xmlCopyString(path_id, buf, BUFLEN);
63 if (strcmp(s, buf)) /* not the same */
64 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
70 printf("Error while fetching node's value.\n");
72 printf("Testing xmlCopyString against xmlCompareString:\t\t\t\t");
73 if (xmlCompareString(path_id, buf)) /* not the same */
74 printf ("failed.\n\t'%s' differs\n", buf);
78 printf("Testing xmlCopyString against xmlNodeCompareString:\t\t\t");
79 if (xmlNodeCompareString(node_id, LEAFNODE, buf)) /* not the same */
80 printf ("failed.\n\t'%s' differs\n", buf);
84 printf("Testing xmlCopyString against xmlNodeGetString:\t\t\t\t");
85 if ((s = xmlNodeGetString(node_id, LEAFNODE)) != 0)
87 if (strcmp(s, buf)) /* not the same */
88 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
94 printf("Error while fetching value from node.\n");
97 path_id = xmlNodeGet(root_id, "/Configuration/backend/name");
100 xmlAttributeCopyString(path_id, "type", buf, BUFLEN);
102 printf("Testing xmlAttributeCopyString against xmlAttributeCompareString:\t");
103 if (xmlAttributeCompareString(path_id, "type", buf)) /* no match */
104 printf("failed.\n\t'%s' differs\n", buf);
108 printf("Testing xmlAttributeCopyString against xmlAttributeGetString:\t\t");
109 if ((s = xmlAttributeGetString(path_id, "type")) != 0)
111 if (strcmp(s, buf)) /* not the same */
112 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
118 printf("Error while fetching value from attribute.\n");
122 printf("Error while fetching node's attribute.\n");
127 path_id = xmlNodeGet(root_id, "Configuration/output/sample/test");
130 xmlNodeCopyString(root_id ,"Configuration/output/menu/name", buf, BUFLEN);
131 printf("Testing xmlCompareString against a fixed string: \t\t\t");
132 if (xmlCompareString(path_id, buf)) /* no match */
133 printf("failed.\n\t'%s' differs\n", buf);
137 s = xmlGetString(path_id);
140 printf("Testing xmlGetString against a fixed string: \t\t\t\t");
141 if (strcmp(s, buf)) /* mismatch */
142 printf("failed.\n\t'%s' differs from\n\t'%s'\n", s, buf);
146 printf("Testing xmlCopyString gainst a fixed string: \t\t\t\t");
147 xmlCopyString(path_id, buf, BUFLEN);
148 if (strcmp(s, buf)) /* mismatch */
149 printf("failed.\n\t'%s' differs from\n\t'%s'\n", s, buf);
161 printf("Error: %s\n", xmlErrorGetString(root_id, 1));