#include #include #include "sxmlclib.h" int process(char *fn) { XMLDoc *doc = malloc(sizeof(XMLDoc)); if (!doc) { fprintf(stderr, "Could not allocate memory for the XMLDoc when trying to parse %s.\n", fn); exit(1); } XMLDoc_init(doc); int ret = XMLDoc_parse_file_DOM(fn, doc); if (!ret) { fprintf(stderr, "Error when parsing file '%s'.\n", fn); return 1; } if (doc->i_root < 0) { fprintf(stderr, "i_root was negative. Skipping file '%s'.\n", fn); return 1; } XMLNode *root = doc->nodes[doc->i_root]; if (!root) { fprintf(stderr, "Root was NULL. Exiting.\n"); return 1; } //get_article_title(root); fprintf(stderr, "root is '%s'.\n", root->tag); XMLDoc_free(doc); return 0; } XMLNode* get_article_title(XMLNode *root) { return root; } int main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { process(argv[i]); } return 0; }