HTML library htmlcxx application instance

Source: Internet
Author: User

I had to parse html for work, but I didn't want to use Microsoft's DomApi. So I went online to find an open-source library and found several good ones.

For example, html tidy and htmlcxx library. I will not repeat it again. I will paste the following example to describe the htmlcxx application:

Parse specific text paragraphs

Std: string strHtml = "<font size = \"-1 \ "color = #808080> dddddd joins the dialog </font> ";

Htmlcxx: HTML: ParserDom parser;
Tree

Tree Tree For (; it! = End; ++ it)
{
Std: string strText;
If (it-> isComment ())
Continue;

If (it-> isTag ())
{
It-> parseAttributes ();
If (it-> tagName () = "font ")
{
Std: pair <bool, std: string> Size = it-> attribute ("size ");
Std: pair <bool, std: string> Color = it-> attribute ("color ");

STD: String strsize = size. Second;
STD: String strcolor = color. Second;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.