Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. void FindLinks(htmlNodePtr element)
  2. {
  3. for(htmlNodePtr node = element; node != NULL; node = node->next)
  4. {
  5. if(node->type == XML_ELEMENT_NODE)
  6. {
  7. if(xmlStrcasecmp(node->name, (const xmlChar*)"A") == 0)
  8. {
  9. for(xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next)
  10. {
  11. if(xmlStrcasecmp(attr->name, (const xmlChar*)"HREF") == 0)
  12. {
  13. printf("Found link <%s>n", node->children->content);
  14. }
  15. }
  16. }
  17. if(node->children != NULL)
  18. {
  19. FindLinks(node->children);
  20. }
  21. }
  22. }
  23. }
  24.  
  25. void ParseHTML(xmlChar* html)
  26. {
  27. htmlDocPtr doc = htmlParseDoc(html, NULL);
  28. if(doc != NULL)
  29. {
  30. htmlNodePtr root = xmlDocGetRootElement(doc);
  31. if(root != NULL)
  32. {
  33. FindLinks(root);
  34. }
  35. xmlFreeDoc(doc);
  36. doc = NULL;
  37. }
  38. }
Add Comment
Please, Sign In to add comment