summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2016-09-01 20:27:00 +0200
committerSilvan Jegen <s.jegen@gmail.com>2016-09-01 20:27:00 +0200
commit581b24aaf0e15313b7dc4160471f907c59a8f34c (patch)
tree20e73c07f8e183b7d48d38fa10abc2cd7ce6a591
parent1c34bb06ead28ef59ae772047a781f9d2e02feff (diff)
Walk the nodes
-rw-r--r--mxml.c24
1 files 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);