From 581b24aaf0e15313b7dc4160471f907c59a8f34c Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Thu, 1 Sep 2016 20:27:00 +0200 Subject: Walk the nodes --- mxml.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mxml.c b/mxml.c index 0b503e4..7d73988 100644 --- a/mxml.c +++ b/mxml.c @@ -21,20 +21,38 @@ mxml_type_t type_cb(mxml_node_t *node) { } int process(FILE *f) { - mxml_node_t *root; + mxml_node_t *root, *node, *next; const char* elename; - root = mxmlLoadFile(NULL, f, type_cb); + root = mxmlLoadFile(NULL, f, MXML_NO_CALLBACK); elename = mxmlGetElement(root); if (elename) printf("%s\n", elename); + + node = mxmlFindElement(root, root, "title-group", + NULL, NULL, MXML_DESCEND); + + elename = mxmlGetElement(node); + if (elename) + printf("%s\n", elename); + + while ((next = mxmlWalkNext(node, root, MXML_DESCEND))) { + elename = mxmlGetElement(next); + if (elename) + printf("%s\n", elename); + // if (!strcmp(elename, "article-title")) + // printf("OMG: %s\n", elename); + + node = next; + } + + return 0; } int main(int argc, char *argv[]) { FILE *f; for (int i = 0; i < argc; i++) { - printf("%s\n", argv[i]); f = fopen(argv[i], "r"); process(f); fclose(f); -- cgit v1.2.3