/* test.c * * Test program to strip all nodes from a file * * To compile: * gcc -o test test.c `pkg-config --cflags --libs libxml-2.0` */ #include void strip_extensions (xmlNode *node) { xmlNode *cur_node = NULL; for (cur_node = node; cur_node; cur_node = cur_node->next) { if (strcmp (cur_node->name, "extensions") == 0) { fprintf (stderr, "Node: %s\n", cur_node->parent->name); xmlUnlinkNode (cur_node); xmlFreeNode (cur_node); } strip_extensions (cur_node->children); } return; } int main (int argc, char *argv[]) { int size; xmlChar *buf; xmlDoc *doc; xmlNode *root; doc = xmlReadFile (argv[1], NULL, 0); root = xmlDocGetRootElement (doc); strip_extensions (root); xmlDocDumpMemory (doc, &buf, &size); fprintf (stdout, "%s", buf); xmlFree (buf); xmlFreeDoc (doc); xmlCleanupParser (); return 0; }