diff --git a/.gitignore b/.gitignore index 3fb0741..908c197 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ build/ *.exp *.opensdf *.suo +*.ilk # windows [Dd]ebug/ @@ -43,4 +44,5 @@ build/ [Bb]bin/ [Bb]oost/ lib/boost/* -*.ilk + + diff --git a/src/html5.cpp b/src/html5.cpp index 4310020..bb5e456 100644 --- a/src/html5.cpp +++ b/src/html5.cpp @@ -459,7 +459,7 @@ bool html::basic_selector::condition::operator()(const html::basic_dom if (it == d.attributes.end()) return false; if (matching_attr_operator == operator_string_equalityt()) - strcmp_ignore_case(it->second, matching_attr_value); + return strcmp_ignore_case(it->second, matching_attr_value); else if (matching_attr_operator == operator_string_contain()) { if (matching_attr_value == selector_empty_string()) return it->second.empty(); diff --git a/test/test.cpp b/test/test.cpp index 229a397..4e061bd 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -6,6 +6,8 @@ const char msg_usage[] = "\nusage : %s \n\n"; + +// 如果你不希望跑命令行解析。那么你可以直接调用这个函数跑一下。 void test(); @@ -15,7 +17,6 @@ void callback(std::shared_ptr) int main(int argc, char *argv[]) { - test(); if (argc < 3) { if (argc > 0) @@ -60,14 +61,22 @@ void test() html::dom page_href_http_node; page.append_partial_html(""); - page.append_partial_html("hello world</title"); + page.append_partial_html("<title id=\"id_test\" href=\"http://www.baidu.com\" bkcolor=\"ff000000\" textcolor=\"ffffffff\">hello world</title"); page.append_partial_html("></head></html>"); - //page["[href='#']"]; - //page["[href!='#']"]; + page = page["#id_test"]; + printf("value : %s \n", page.to_plain_text().c_str()); + + page["[href]"]; + printf("value : %s \n", page.to_plain_text().c_str()); page = page["[href$='http']"]; + printf("value : %s \n", page.to_plain_text().c_str()); + + page = page["[bkcolor='ff000000']"]; + printf("value : %s \n", page.to_plain_text().c_str()); + page = page["[textcolor!='ff000000']"]; printf("value : %s \n", page.to_plain_text().c_str()); }