#include <libxml/parser.h>

static void
parse_entry(xmlDocPtr doc, xmlNodePtr cur, int argc, char **search)
{
	cur = cur->xmlChildrenNode;
	while (cur) {
		int i;
		for (i = 2; i < argc; i++) {
			if (!xmlStrcmp(cur->name, (const xmlChar *) search[i]) &&
			     xmlNodeListGetString(doc, cur->xmlChildrenNode, 1))
				printf("%s\n", xmlNodeListGetString(doc,
							cur->xmlChildrenNode, 1));
		}
		cur = cur->next;
	}
}

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

	if (argc < 3)
		return 0;

	if (!(doc = xmlParseFile(argv[1])))
		return 1;
	if (!(cur = xmlDocGetRootElement(doc)))
		return 1;

	while (cur) {
		xmlNodePtr chl = cur->xmlChildrenNode;
		if (xmlStrcmp(cur->name, (const xmlChar *) "livejournal")) {
			cur = cur->next;
			continue;
		}
		while (chl) {
			if (!xmlStrcmp(chl->name, (const xmlChar *) "entry"))
				parse_entry(doc, chl, argc, argv);
			chl = chl->next;
		}
		cur = cur->next;
	}

	return 0;
}
