Sample code for 30+ languages & platforms
PureBasic

Convert HTML to Plain Text

Demonstrates how to convert HTML to plain text.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHtmlToText.pb"

Procedure ChilkatExample()

    ; This example requires the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    h2t.i = CkHtmlToText::ckCreate()
    If h2t.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    html.s = CkHtmlToText::ckReadFileToString(h2t,"c:/temp/test.html","utf-8")
    If CkHtmlToText::ckLastMethodSuccess(h2t) = 0
        Debug CkHtmlToText::ckLastErrorText(h2t)
        CkHtmlToText::ckDispose(h2t)
        ProcedureReturn
    EndIf

    plainText.s = CkHtmlToText::ckToText(h2t,html)
    If CkHtmlToText::ckLastMethodSuccess(h2t) = 0
        Debug CkHtmlToText::ckLastErrorText(h2t)
        CkHtmlToText::ckDispose(h2t)
        ProcedureReturn
    EndIf

    Debug plainText


    CkHtmlToText::ckDispose(h2t)


    ProcedureReturn
EndProcedure