From 7136cf7c9198f6ffb9e693e029143fea460cf760 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Thu, 8 Sep 2016 21:33:45 +0200 Subject: Print the article-title For some reason the article-title tags get never closed. Instead of checking the name of the closed element name, we just check if we are in the element we are searching for or not. As long as the element whose content we want to print does not have any nested elements itself this approach works as well. --- yxml.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yxml.c b/yxml.c index b55999a..1fd0f51 100644 --- a/yxml.c +++ b/yxml.c @@ -93,6 +93,7 @@ int process(char *fn, yxml_t *state) { switch(r) { case YXML_ELEMSTART: if (!strcmp(state->elem, "article-title")) { + printf("start: %s\n", state->elem); inelement = 1; } break; @@ -104,12 +105,12 @@ int process(char *fn, yxml_t *state) { break; case YXML_ELEMEND: - if (strcmp(state->elem, "article-title")) { - break; + printf("elementend: %s\n", state->elem); + if (inelement) { + inelement = 0; + printf("%s\n", contentbuf->buffer); + buffer_reset(contentbuf); } - inelement = 0; - printf("%s\n", contentbuf->buffer); - buffer_reset(contentbuf); break; } } -- cgit v1.2.1-18-gbd029