You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
html::parser p;
html::node_ptr node = p.parse("<ul><li>li1</li><li>li2</li></ul><ol><li>li</li></ol>");
// method takes two arguments, the indentation character and whether to output child elements (tabulation and true by default)
std::cout << node->to_html('', true) << std::endl;
Print text content of a node
html::parser p;
html::node_ptr node = p.parse("<div><p><b>First</b> p</p><p><i>Second</i> p</p>Text<br />Text</div>");
// print text with line breaks preserved
std::cout << node->to_text() << std::endl << std::endl;
// print text with line breaks replaced with spaces
std::cout << node->to_text(true) << std::endl;
Building HTML from DOM tree
auto p = html::utils::make_node(html::node_t::tag, "p", {{"id", "p_id"}, {"class", "p_class"}});
p->append(html::utils::make_node(html::node_t::text, "Link:"));
p->append(html::utils::make_node(html::node_t::tag, "br"));
auto a = html::utils::make_node(html::node_t::tag, "a", {{"href", "https://github.com/"}});
p->append(a);
a->append(html::utils::make_node(html::node_t::text, "Github.com"));
std::cout << html::utils::make_node(html::node_t::tag, "div")->append(p)->to_html() << std::endl;