- const xmlNode *parent = node->parent;
- if (parent->type == XML_ELEMENT_NODE)
- printf ("%s %s\n", parent->name, node->name);
- else if (parent->type == XML_DOCUMENT_NODE)
- printf ("<root> %s\n", node->name);
+ for (xmlNode *child = node->children; child; child = child->next)
+ {
+ if (child->type == XML_ELEMENT_NODE)
+ printf ("%s %s\n", node->name, child->name);
+ else if (child->type == XML_TEXT_NODE)
+ printf ("%s <text>\n", node->name);
+ else if (child->type == XML_CDATA_SECTION_NODE)
+ printf ("%s <cdata>\n", node->name);
+ else if (child->type == XML_COMMENT_NODE)
+ printf ("%s <comment>\n", node->name);
+ else
+ printf ("%s <%d>\n", node->name, child->type);
+ }
+ }
+
+ print_parents (node->children);
+ }
+}
+
+static void
+print_containment (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE)
+ {
+ const char *child_names[512];
+ int child_name_cnt[512];
+ int n_names = 0;
+ for (xmlNode *child = node->children; child; child = child->next)
+ {
+ const char *name;
+
+ if (child->type == XML_ELEMENT_NODE)
+ name = (char *) child->name;
+ else if (child->type == XML_TEXT_NODE)
+ name = "<text>";
+ else if (child->type == XML_CDATA_SECTION_NODE)
+ name = "<cdata>";
+ else if (child->type == XML_COMMENT_NODE)
+ {
+ name = "<comment>";
+ //printf ("comment %s\n", (char *) child->content);
+ continue;
+ }
+ else
+ name = "<other>";
+
+ for (int i = 0; i < n_names; i++)
+ if (!strcmp(name, child_names[i]))
+ {
+ child_name_cnt[i]++;
+ goto next;
+ }
+ child_names[n_names] = name;
+ child_name_cnt[n_names] = 1;
+ n_names++;
+
+ next:;
+ }
+
+ printf ("%s", node->name);
+ for (int i = 0; i < n_names; i++)
+ {
+ printf (" %s", child_names[i]);
+ if (child_name_cnt[i] > 1)
+ printf ("+");
+ }
+ printf ("\n");