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;
18 path_id = xmlNodeGet(root_id, PATH);
19 node_id = xmlNodeGet(root_id, ROOTNODE);
21 if (path_id && node_id)
27 len = xmlNodeCopyString(root_id, PATH, buf, BUFLEN);
28 printf("%s = '%s'\n", PATH, buf);
30 printf("Testing value of /Configuration/output/test:\t\t\t\t");
31 s = xmlNodeGetString(root_id , "/Configuration/output/test");
34 printf("failed.\n\t'%s' shoudl be empty\n", s);
40 printf("Testing xmlNodeCopyString against xmlGetString:\t\t\t\t");
41 if ((s = xmlGetString(path_id)) != 0)
43 if (strcmp(s, buf)) /* not the same */
44 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
48 printf("Testing xmlCopyString against xmlGetString:\t\t\t\t");
49 xmlCopyString(path_id, buf, BUFLEN);
50 if (strcmp(s, buf)) /* not the same */
51 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
57 printf("Error while fetching node's value.\n");
59 printf("Testing xmlCopyString against xmlCompareString:\t\t\t\t");
60 if (xmlCompareString(path_id, buf)) /* not the same */
61 printf ("failed.\n\t'%s' differs\n", buf);
65 printf("Testing xmlCopyString against xmlNodeCompareString:\t\t\t");
66 if (xmlNodeCompareString(node_id, LEAFNODE, buf)) /* not the same */
67 printf ("failed.\n\t'%s' differs\n", buf);
71 printf("Testing xmlCopyString against xmlNodeGetString:\t\t\t\t");
72 if ((s = xmlNodeGetString(node_id, LEAFNODE)) != 0)
74 if (strcmp(s, buf)) /* not the same */
75 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
81 printf("Error while fetching value from node.\n");
84 path_id = xmlNodeGet(root_id, "/Configuration/backend/name");
87 xmlAttributeCopyString(path_id, "type", buf, BUFLEN);
89 printf("Testing xmlAttributeCopyString against xmlAttributeCompareString:\t");
90 if (xmlAttributeCompareString(path_id, "type", buf)) /* no match */
91 printf("failed.\n\t'%s' differs\n", buf);
95 printf("Testing xmlAttributeCopyString against xmlAttributeGetString:\t\t");
96 if ((s = xmlAttributeGetString(path_id, "type")) != 0)
98 if (strcmp(s, buf)) /* not the same */
99 printf("failed.\n\t'%s' differs from '%s'\n", s, buf);
105 printf("Error while fetching value from attribute.\n");
109 printf("Error while fetching node's attribute.\n");
116 printf("Error: %s\n", xmlErrorGetString(root_id, 1));