#include #include #include "ezxmllib.h" int process(char *fn) { ezxml_t ezdoc = ezxml_parse_file(fn); if (!ezdoc) { fprintf(stderr, "Error when parsing file.\n"); } ezxml_t title = ezxml_get(ezdoc, "front", 0, "article-meta", 0, "title-group", 0, "article-title", -1); if (title) { printf("article-title: %s\n", title->txt); } ezxml_t body = ezxml_get(ezdoc, "body", -1); if (!body) { fprintf(stderr, "Body not found\n"); } for (ezxml_t c = ezxml_child(body, "sec"); c; c = c->next) { ezxml_t t = ezxml_get(c, "title", -1); printf("t: %s\n", t->txt); } printf("\n"); return 0; } int main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { process(argv[i]); } return 0; }