summaryrefslogtreecommitdiff
path: root/src/test-subclassing.c
blob: dd099e44046d5f41bf960f3465bce5b2694915ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <libxml/tree.h>
#include <stdio.h>
#include <string.h>

int
main (int    argc,
      char **argv)
{
	xmlDocPtr doc;
	xmlNodePtr node;

	doc = xmlReadFile ("freedesktop.org.xml", NULL, 0);
	if (doc == NULL) {
		fprintf (stderr, "Reading \"freedesktop.org.xml\" failed. Aborting.\n");
		return 1;
	}

	if ((node = xmlDocGetRootElement (doc)) == NULL) {
		fprintf (stderr, "\"freedesktop.org.xml\" has no root node. Aborting.\n");
		return 1;
	}

	for (node = node->children; node != NULL; node = node->next) {
		if (!strcmp ((char *) node->name, "mime-type")) {
			xmlNodePtr p;
			xmlChar *prop;

			for (p = node->children; p != NULL; p = p->next) {
				if (!strcmp ((char *) p->name, "sub-class-of")) {
					break;
				}
			}

			if (p != NULL) {
				/* got sub-class-of node */
				continue;
			}

			prop = xmlGetProp (node, (xmlChar *) "type");
			printf ("%s\n", prop);
			xmlFree (prop);
		}
	}

	xmlFreeDoc (doc);
	return 0;
}