首页 > Web开发 > 详细

htmlcxx取指定字段实例

时间:2015-04-13 18:08:00      阅读:132      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!