views:

15

answers:

0

I'm trying to parse an HTML file saved in memory. I'm fetching the HTML with libcurl and save it in memory as string.

I'm having problems parsing this html with the HTMLparser module.

I'm looking for a short guideline on how to parse and walk on this parsed html using libxml2 HTMLparser module with c++

Thanks

EDIT: I'm getting this error on Eclipse During startup program exited with code 0xc0000135 When using this code:

xmlNode *root_element = NULL;
  doc = htmlReadMemory(reportPage.c_str(), reportPage.size(), "html", NULL, HTML_PARSE_RECOVER|HTML_PARSE_NOERROR|HTML_PARSE_NOWARNING);
  if (doc == NULL)
  {
      cout<< "Failed to parse document" << endl;
      return;
  }

    /*Get the root element node */
    root_element = xmlDocGetRootElement(doc);

    print_element_names(root_element);

  xmlFreeDoc(doc);
  xmlCleanupParser();