-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception at 0x1e34a6, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance) #136
Comments
I need to know what to contain in if (classname_list->list[i]->child != NULL) {
myhtml_collection_t *text = myhtml_get_nodes_by_tag_id_in_scope(tree, NULL, classname_list->list[i]->child, MyHTML_TAG__TEXT, NULL);
if (text != NULL && text.length != 0) {
const char *t = myhtml_node_text(text->list[0], NULL);
/* do what you want */
}
myhtml_collection_destroy(text);
} |
classname_list is get as follows: |
May be it's a problem of html encoding? |
This code work fine: const char* data = "<p class=\"name\" style=\"padding-left: 5px;\">\n\t\t\t\t\t<a href=\"javascript:;\" class=\"pic\" onclick=\"ToPdfReadBook(13863989,0)\" style=\"font-size: 14px;\" title=\"经济学 微观部分\">《经济学 微观部分》\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t";
myhtml_t* myhtml = myhtml_create();
myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 2, 0);
myhtml_tree_t* tree = myhtml_tree_create();
myhtml_tree_init(tree, myhtml);
myhtml_parse(tree, MyENCODING_UTF_8, data, strlen(data));
myhtml_collection_t *classname_list = myhtml_get_nodes_by_attribute_value(tree, NULL, NULL, false, "class", strlen("class"), "name", strlen("name"), NULL);
for (size_t i = 0 ; i < classname_list->length; i++) {
myhtml_collection_t *text = myhtml_get_nodes_by_tag_id_in_scope(tree, NULL, classname_list->list[i], MyHTML_TAG__TEXT, NULL);
for (size_t j = 0 ; j < text->length; j++) {
const char *t = myhtml_node_text(text->list[j], NULL);
printf("%s\n", t);
}
myhtml_collection_destroy(text);
}
myhtml_collection_destroy(classname_list);
myhtml_tree_destroy(tree);
myhtml_destroy(myhtml); in |
Problem solved, Thanks! |
another problem, the code as follows:
the result is 《经济学聽聽微观部分》, but my need data is 《经济学 微观部分》. |
I do not understand, in your example there is no |
html is: "<p class="name" style="padding-left: 5px;">\n\t\t\t\t\t<a href="javascript:;" class="pic" onclick="ToPdfReadBook(13863989,0)" style="font-size: 14px;" title="经济学 微观部分">《经济学 微观部分》\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
"when i use
myhtml_collection_t *text=myhtml_get_nodes_by_tag_id_in_scope(tree,NULL,classname_list->list[i]->child,MyHTML_TAG__TEXT, NULL);
const char *t=myhtml_node_text(text->list[0],NULL);
then error code is show in debug view.
i want to known the reason.Please help me
The text was updated successfully, but these errors were encountered: