From c5ac33dcd1ec134b860049cfad235d01bde0bf3e Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Thu, 1 Sep 2016 20:56:52 +0200 Subject: Get Text node --- mxml.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mxml.c b/mxml.c index 7d73988..df49af4 100644 --- a/mxml.c +++ b/mxml.c @@ -24,7 +24,7 @@ int process(FILE *f) { mxml_node_t *root, *node, *next; const char* elename; - root = mxmlLoadFile(NULL, f, MXML_NO_CALLBACK); + root = mxmlLoadFile(NULL, f, MXML_TEXT_CALLBACK); elename = mxmlGetElement(root); if (elename) printf("%s\n", elename); @@ -38,10 +38,20 @@ int process(FILE *f) { while ((next = mxmlWalkNext(node, root, MXML_DESCEND))) { elename = mxmlGetElement(next); - if (elename) + if (elename) { printf("%s\n", elename); - // if (!strcmp(elename, "article-title")) - // printf("OMG: %s\n", elename); + if (!strcmp(elename, "article-title")) { + next = mxmlWalkNext(next, root, MXML_DESCEND); + mxml_type_t t = mxmlGetType(next); + printf("T %d\n", t); + if (t == MXML_TEXT) { + printf("IS TEXT %d\n", t); + } + const char* txt = mxmlGetText(next, NULL); + if (txt) + printf("article-title txt: %s\n", txt); + } + } node = next; } -- cgit v1.2.3