zoukankan      html  css  js  c++  java
  • htmlcxx取指定字段实例

    #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;

    }

  • 相关阅读:
    OleView.exe:查看机器上的COM 组件。
    COM中导出GUID
    进程外组件以及进程间通信方式
    拼接多个 wchar_t *
    wstring to wchar_t*
    BSTR
    GetProcAddress 使用注意事项
    C++和.net的集合类对应
    COM的一些基本概念
    Error Lookup工具
  • 原文地址:https://www.cnblogs.com/dancheblog/p/4422533.html
Copyright © 2011-2022 走看看