Changeset 4723
- Timestamp:
- Feb 1, 2011, 1:59:39 PM (10 years ago)
- Location:
- gaycko/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gaycko/trunk/src/dom/dom.c
r4716 r4723 29 29 e->children_count = 0; 30 30 e->children = NULL; 31 31 e->attribute_count = 0; 32 32 e->attributes = NULL; 33 33 34 34 e->name = (char*)strdup((const char*)node->name); 35 35 … … 51 51 e->type = ELEM_P; 52 52 }else if(!strncmp(e->name, "img", 3)) { 53 54 53 e->type = ELEM_IMG; 54 }else if(!strncmp(e->name, "text", 4)) { 55 55 e->type = ELEM_TEXT; 56 56 e->text = (char*)strdup((const char*)xmlNodeGetContent(node)); 57 58 57 strip_eol(e->text); 58 strip_spaces(e->text); 59 59 }else { 60 60 e->type = ELEM_UNKNOW; 61 61 printf("Unknow tag '%s'\n", e->name); 62 62 } 63 64 65 66 67 68 69 70 71 63 64 if(node->properties) { 65 for(xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next) { 66 e->attributes = realloc(e->attributes, sizeof(gAttribute)); 67 e->attributes[e->attribute_count].name = strdup(attr->name); 68 e->attributes[e->attribute_count].value = strdup(attr->children->content); 69 } 70 } 71 72 72 return e; 73 73 } … … 81 81 gElement *child = add_element(node); 82 82 child->level = level; 83 83 84 84 if(elem) elem = realloc(elem, sizeof(gElement*)*(c+1)); 85 85 else elem = malloc(sizeof(gElement*)); … … 94 94 if(node->children != NULL) { 95 95 explore(child->children, 96 node->children,97 level+1,98 child);96 node->children, 97 level+1, 98 child); 99 99 } else { 100 100 free(child->children); … … 125 125 LEVEL printf("<%s>\n", elem->name); 126 126 } 127 127 128 128 unsigned int i; 129 129 for(i=0; i < elem->children_count; i++) { … … 138 138 } 139 139 140 141 #if 0142 if(xmlStrcasecmp(node->name, (const xmlChar*)"A") == 0)143 {144 for(xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next)145 {146 if(xmlStrcasecmp(attr->name, (const xmlChar*)"HREF") == 0)147 {148 printf("Found link <%s>\n", node->children->content);149 }150 }151 }152 #endif153 -
gaycko/trunk/src/parsing/parse.c
r4720 r4723 27 27 /* Actual parsing */ 28 28 htmlDocPtr doc = htmlParseDoc((unsigned char*)output.bp, NULL); 29 30 31 //tidyBufFree( &output ); 32 //tidyBufFree( &errbuf ); 29 30 /* Release tidy document */ 33 31 tidyRelease( tdoc ); 34 32 33 /* Convert libxml2's tree to our own DOM */ 34 gDOM *dom = gaycko_convert_dom(doc); 35 35 36 gDOM *dom = gaycko_convert_dom(doc); 36 /* Free libxml2 tree */ 37 xmlFreeDoc(doc); 37 38 38 39 return dom;
Note: See TracChangeset
for help on using the changeset viewer.