From b8adea2079845494bb7c8c6946bdaadc57a4d271 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 22 Dec 2011 11:59:57 +0000 Subject: Fix length for dom_string creation. Dump id attribute too. svn path=/trunk/libdom/; revision=13326 --- examples/dom-structure-dump.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c index 3c073e4..bd73799 100644 --- a/examples/dom-structure-dump.c +++ b/examples/dom-structure-dump.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -153,7 +154,7 @@ bool dump_dom_element_attribute(dom_node_internal *node, char *attribute) assert(type == DOM_ELEMENT_NODE); /* Create a dom_string containing required attribute name. */ - exc = dom_string_create((uint8_t *)attribute, 5, &attr); + exc = dom_string_create((uint8_t *)attribute, strlen(attribute), &attr); if (exc != DOM_NO_ERR) { printf(" Exception raised for dom_string_create\n"); return false; @@ -238,8 +239,10 @@ bool dump_dom_element(dom_node_internal *node, int depth) /* Finished with the node_name dom_string */ dom_string_unref(node_name); - /* Print the element's class, if it has one */ - if (dump_dom_element_attribute(node, "class") == false) { + /* Print the element's id & class, if it has them */ + if (dump_dom_element_attribute(node, "id") == false || + dump_dom_element_attribute(node, "class") == false) { + /* Error occured */ printf("\n"); return false; } -- cgit v1.2.3