diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-12-22 11:59:57 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-12-22 11:59:57 +0000 |
commit | b8adea2079845494bb7c8c6946bdaadc57a4d271 (patch) | |
tree | 01a0c520782e02d13e553dde11331c486f282630 | |
parent | f4ceb7833993573189dc71cd9662ab01312c6185 (diff) | |
download | libdom-b8adea2079845494bb7c8c6946bdaadc57a4d271.tar.gz libdom-b8adea2079845494bb7c8c6946bdaadc57a4d271.tar.bz2 |
Fix length for dom_string creation. Dump id attribute too.
svn path=/trunk/libdom/; revision=13326
-rw-r--r-- | examples/dom-structure-dump.c | 9 |
1 files changed, 6 insertions, 3 deletions
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 <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <dom/dom.h> #include <dom/bindings/hubbub/parser.h> @@ -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; } |