From d2b8fd13b03503a259275387f07210aaf27e8d9a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Sep 2022 04:59:03 +0200 Subject: get attributes with node instead --- include/quickmedia/HtmlSearch.h | 2 +- src/HtmlSearch.c | 4 ++-- tests/main.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/quickmedia/HtmlSearch.h b/include/quickmedia/HtmlSearch.h index c0bd17c..e2b0ecc 100644 --- a/include/quickmedia/HtmlSearch.h +++ b/include/quickmedia/HtmlSearch.h @@ -55,7 +55,7 @@ typedef struct { The result is stripped of whitespace on the left and right side. Case insensitive search. */ -QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaMatchNode *self, const char *attribute_name); +QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaHtmlNode *self, const char *attribute_name); /* Returns an empty string if the node doesn't have any text or if there was an error creating the text. diff --git a/src/HtmlSearch.c b/src/HtmlSearch.c index 45d8aa4..cdd4759 100644 --- a/src/HtmlSearch.c +++ b/src/HtmlSearch.c @@ -416,12 +416,12 @@ static int html_parse_callback(HtmlParser *html_parser, HtmlParseType parse_type return 0; } -QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaMatchNode *self, const char *attribute_name) { +QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaHtmlNode *self, const char *attribute_name) { QuickMediaStringView attr_name; attr_name.data = attribute_name; attr_name.size = strlen(attribute_name); - QuickMediaHtmlAttribute *attr = get_attribute_by_name(self->node, attr_name); + QuickMediaHtmlAttribute *attr = get_attribute_by_name(self, attr_name); if(attr) { QuickMediaStringView attr_value = attr->value; strip(attr_value.data, attr_value.size, &attr_value.data, &attr_value.size, is_whitespace); diff --git a/tests/main.c b/tests/main.c index 2a08ec7..ac3a081 100644 --- a/tests/main.c +++ b/tests/main.c @@ -20,7 +20,7 @@ static char* get_file_content(const char *filepath, size_t *filesize) { } static int result_callback(QuickMediaMatchNode *node, void *userdata) { - QuickMediaStringView href = quickmedia_html_node_get_attribute_value(node, "href"); + QuickMediaStringView href = quickmedia_html_node_get_attribute_value(node->node, "href"); QuickMediaStringView text = quickmedia_html_node_get_text(node); printf("a href: %.*s, node value: %.*s\n", (int)href.size, href.data, (int)text.size, text.data); return 0; -- cgit v1.2.3