Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FindLinks(htmlNodePtr element)
- {
- for(htmlNodePtr node = element; node != NULL; node = node->next)
- {
- if(node->type == XML_ELEMENT_NODE)
- {
- if(xmlStrcasecmp(node->name, (const xmlChar*)"A") == 0)
- {
- for(xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next)
- {
- if(xmlStrcasecmp(attr->name, (const xmlChar*)"HREF") == 0)
- {
- printf("Found link <%s>n", node->children->content);
- }
- }
- }
- if(node->children != NULL)
- {
- FindLinks(node->children);
- }
- }
- }
- }
- void ParseHTML(xmlChar* html)
- {
- htmlDocPtr doc = htmlParseDoc(html, NULL);
- if(doc != NULL)
- {
- htmlNodePtr root = xmlDocGetRootElement(doc);
- if(root != NULL)
- {
- FindLinks(root);
- }
- xmlFreeDoc(doc);
- doc = NULL;
- }
- }
Add Comment
Please, Sign In to add comment