線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:964
推到 Plurk!
推到 Facebook!

有人寫過html to txt的程式嗎

答題得分者是:qoo1234
ks0741
一般會員


發表:11
回覆:5
積分:3
註冊:2003-03-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-17 14:37:35 IP:140.125.xxx.xxx 未訂閱
不知道有沒有人寫過html to txt的程式嗎? 或是有人有範例可以給我看 或是有人知道那邊有. 請告訴我一下,謝謝!
Windyboy
版主


發表:7
回覆:119
積分:210
註冊:2002-11-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-17 14:51:33 IP:61.59.xxx.xxx 未訂閱
你可以把一個HTML檔內的所有TAG都拿掉, 把HTML檔中的所有資料當成一個String, 將<...>全部Delete, 這樣留下來的資料就只有文字^_^ 不知道你的問題是不是這樣..
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-07-17 21:05:59 IP:61.216.xxx.xxx 未訂閱
請參閱阿子 副站..文章 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=33222    網海無涯,學無止境!
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-07-17 21:08:46 IP:61.216.xxx.xxx 未訂閱
另一種寫法:     
 
    !**************************************
    ! for :easy html stripping
    !**************************************
    If you read and understand it before you use it, feel free to do so. If you just copy paste it and delete all my comments, I will kill you :p
    !**************************************
    ! Name: easy html stripping
    ! Description:It's just a function that takes a string, and takes out anything between <>'s. This can be used as a html stripper
    ! By: Willem Wollebrants
    !
    !
    ! Inputs:strip(string_with_html_tags)
    !
    ! Returns:string_without_html_tags!
    !
    !Assumes:None
    !
    !Side Effects:none that I know of
    !This code is copyrighted and has limited warranties.
    !Please see http://www.1PHPStreet.com/xq/ASP/txtCodeId.1155/lngWId.7/qx/vb/scripts/ShowCode.htm
    !for details.
    !**************************************
    
    //-------------------------------------------------------
    // Author: Willem Wollebrants (willemwollebrants@hotmail.com)
    // Date : June 11, 2003
    // What it does : Takes a string, then strips any text between <>'s
    //(html tag stripper really
    // Notes: It's the first code I release. Hope it helps you
    //Don't just copy paste, try to understand how it works.
    //-------------------------------------------------------
    function strip(shtml: string ): string;
            //shtml is the string with the html code we want to strip
    var
    HPos, Len: integer;
            //Hpos will store where our html tag starts
            //Len is the length of the tag
    begin
    //find the first < in the string
    HPos := Pos( '<', shtml );
    //now get the distance to the first >, this gives us the length
    Len := Pos( '>', shtml ) - Pos( '<', shtml )   1;
            //the  1 is a correction for the fact that pos() counts 0,1,2,
    //so we need to add 1 to get it right (or our > maybe left standing there)
    while(nHPos > 0)do
    //while we still can find < in the string
    begin
    //delete the tag
    Delete( shtml, nHPos, nLen );
    //insert an empty space, a bit obsolete
    //but can be usefull if you want to replace the tags by other text
    Insert( '', shtml, nHPos );
    //check for other <
    nHPos := Pos( '<', shtml );
    //and set the length again
    nLen := Pos( '>', shtml ) - Pos( '<', shtml )   1;
    end;
    //finally give us the result
    Result := shtml;
    end;
    //usage: text1.text = strip(<html>Hi everybody</html>)    
網海無涯,學無止境!
系統時間:2024-04-28 16:52:14
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!