2 #include <libxml/parser.h>
3 #include <libxml/tree.h>
5 static void show_one_node(int i, xmlNode *node)
7 static const char indent[] = " ..";
9 if (i >= sizeof(indent))
11 printf("%.*snode '%s': %s\n", i, indent, node->name, node->content);
14 static void show(int indent, xmlNode *node)
18 for (n = node; n; n = n->next) {
19 show_one_node(indent, n);
20 show(indent+2, n->children);
24 static void parse(const char *filename)
28 doc = xmlReadFile(filename, NULL, 0);
30 fprintf(stderr, "Failed to parse '%s'.\n", filename);
34 show(0, xmlDocGetRootElement(doc));
39 int main(int argc, char **argv)
45 for (i = 1; i < argc; i++)