例如:
<html>
<head>
<title> Test </title>
</head><body>
<font = 5><b>Hello World!</b></font>
</body>
</html>只保留
Test 和
Hello World!

解决方案 »

  1.   

    用解析器 读到你想保存的内容如:Test 和 Hello World!,
    然后打开Txt文件,写入其中,再关闭文件。
      

  2.   

    html2text嘛.好多这种程序呢.其实可以很简单就弄出来了
      

  3.   

    说不如做,下面的程序试试
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <list>
    #include <algorithm>
    #include <iterator>
    using namespace std;
    int main()
    {
     string strin,strout;
     cout<<"Enter the html(input) file: ";
     cin>>strin;
     cout<<"\nEnter the txt(output) file: ";
     cin>>strout;
     ifstream filein(strin.c_str());
      if ( !filein )
      {
        cerr << "file could not be opened!";
        exit( 1 );
      }
      ofstream fileout(strout.c_str());
      if ( !fileout)
      {
        cerr << "file could not be opened!";
        exit( 1 );
      }
     bool check;
     list<char> charline;
    char ch;
     filein.seekg( 0 );
      while ( filein.get( ch ) )
      {
      if(ch=='<')
     {
       check=false;
       continue;
     }
     if(check)
      charline.push_back(ch);
     if(ch=='>')
       check=true; 
    }
    copy(charline.begin(),charline.end(),ostream_iterator<char>(fileout));
    return 0;
    }
      

  4.   

    To:crossingxb(沧浪之水)我目前只会C
    但也大致看懂了你的代码!
    对于一般情况,你的做法能得到正确的结果但对于一般意义的"<"和">"却不能正确区分
    in.txt
    1<2out.txt
    1
      

  5.   

    html文件里是不会有一般意义的"<"和">"符号的
      

  6.   

    可以参考这个
    http://www.hackhome.com/2004/9-8/19133.html
      

  7.   

    crossingxb(沧浪之水)的方法是可行的,如果显示内容里有"<"或">"或空格等是会转义的,如">"在html里是"&gt;",你可以用fontpage试一下,所以在你在你用crossingxb(沧浪之水)的方法得到字符串后还要把"&gt;"之类的再替换回">"等