码迷,mamicode.com
首页 > Web开发 > 详细

htmlcxx取指定字段实例

时间:2015-04-13 18:08:14      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

#include <string>

#include <iostream>

#include <sstream>

#include <htmlcxx/html/ParserDom.h>

#include <stdlib.h>

#include <stdio.h>

#include <unistd.h>

 

using namespace std;

using namespace htmlcxx;

 

int main()

{

  std::string strHtml = "<font size=\"-1\" color=#808080>dddddd 加入了对话</font>";

  htmlcxx::HTML::ParserDom parser ;
  tree<htmlcxx::HTML::Node> dom = parser.parseTree(strHtml) ;

  tree<htmlcxx::HTML::Node>::iterator it = dom.begin();

  tree<htmlcxx::HTML::Node>::iterator end = dom.end();

  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;

      }

    }

  }

  return 0;

}

 

htmlcxx取指定字段实例

标签:

原文地址:http://www.cnblogs.com/dancheblog/p/4422533.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!