R
R
raster2022-01-05 16:16:39
visual studio
raster, 2022-01-05 16:16:39

How to include htmlcxx in C++ project?

I found the library of interest: htmlcxx. I just can't figure out how to include it in the project.
It, as I understand it, is not header-only, so simply writing include does not work. I also couldn't find anything on the Internet about the connection. Downloaded from her repository .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor Bomberow, 2022-01-05
@Rastr_0

In this case, the library is distributed as a set of files, and if you build through Msbuild, the easiest way is to add all the library files to the current project directly. Or arrange the assembly with a separate vcproj project of the library in the same solution.
UPDATED:
It seems that either has not been finalized yet, because. in docks the assembly under Win is not explicitly specified.
1) In such cases, first of all, you need to search and view all text files in the archive that are named without an extension. In this case, the archive already contains project files for building through visual studio. To build, you only need to make a solution.
2) Create a new solution with a launch without code or through opening in Explorer on one of the projects. Right-click the solution context menu in the Solution Explorer and add the second project to the solution.
3) Build the htmlcxx.vcxproj project in two configurations. If you do not change anything when importing, this is a static library project.
4) To build the project with a simple CLI (htmlcxxapp.vcxproj), you need to add the folders where the lib was going - project properties - Linker - Additional include directories. If sln was created via project import, then sln will be created in the same folder as the projects, and by default the build path can be set like this $(ProjectDir)$(Configuration)
5) Linker - Additional Dependencies before %(AdditionalDependencies) you can simply add htmlcxx.lib for all configurations, because In debugging, the lib is collected under the same name.
6) after that everything will be assembled. But parsing will not work under Win css.
because

#ifdef WIN32
    if(parse_css)
    {
      cerr << "Css parsing not supported in win32" << endl;
      return 1;
    }
    return 0;
#else

But, here you already need to figure out why you can’t just take it and assemble it under win, and refine it.

S
Satisfied IT, 2022-01-05
specialist @borisdenis

You can find an example using your link :

Using htmlcxx is quite simple. Take a look
at this example.

-----------------------------------------------------------------------

#include <htmlcxx/html/ParserDom.h>
  ...
  using namespace std;
  using namespace htmlcxx;

  //Parse some html code
  string html = "<html><body>hey</body></html>";
  HTML::ParserDom parser;
  tree<HTML::Node> dom = parser.parseTree(html);

  //Print whole DOM tree
  cout << dom << endl;

  //Dump all links in the tree
  tree<HTML::Node>::iterator it = dom.begin();
  tree<HTML::Node>::iterator end = dom.end();
  for (; it != end; ++it)
  {
     if (strcasecmp(it->tagName().c_str(), "A") == 0)
     {
       it->parseAttributes();
       cout << it->attribute("href").second << endl;
     }
  }

  //Dump all text of the document
  it = dom.begin();
  end = dom.end();
  for (; it != end; ++it)
  {
    if ((!it->isTag()) && (!it->isComment()))
    {
      cout << it->text();
    }
  }
  cout << endl;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question