#ifndef HTML_PARSER_H
#define HTML_PARSER_H
#include
#include
#include
class HtmlParser {
public:
HtmlParser() = delete;
HtmlParser(const std::string &html) {
doc = htmlReadDoc((xmlChar*)html.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
auto r = xmlDocGetRootElement(doc);
root.reset(new xmlpp::Element(r));
}
~HtmlParser() {
xmlFreeDoc(doc);
}
xmlpp::Element &getRoot() {
return *root;
}
private:
xmlDoc *doc;
std::unique_ptr root;
};
#endif