+static void
+print_element (xmlDoc *doc, xmlNode *node, const char *element)
+{
+ for (; node; node = node->next)
+ {
+ if (node->name && !strcmp(element, (char *) node->name))
+ {
+ xmlBuffer *buf = xmlBufferCreate();
+ xmlNodeDump (buf, doc, node, 0, 1);
+ xmlBufferDump (stdout, buf);
+ xmlBufferFree (buf);
+ putchar ('\n');
+ }
+
+ print_element (doc, node->children, element);
+ }
+}
+
+static __attribute__((unused)) xmlNode *
+find_page_setup (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->name && !strcmp ((char *) node->name, "pageSetup"))
+ return node;
+
+ xmlNode *ps = find_page_setup (node->children);
+ if (ps)
+ return ps;
+ }
+ return NULL;
+}
+
+static void
+print_text (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE)
+ {
+ printf ("%s", node->name);
+ for (xmlNode *child = node->children; child; child = child->next)
+ if (child->type == XML_TEXT_NODE)
+ {
+ putchar (' ');
+ print_string (child->content);
+ }
+ putchar ('\n');
+ }
+
+ print_text (node->children);
+ }
+}
+