Sample code for 30+ languages & platforms
PureBasic

Convert HTML to plain-text

See more HTML-to-XML/Text Examples

Demonstrates how to convert HTML to plain-text.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHtmlToText.pb"

Procedure ChilkatExample()

    ; This example assumes 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

    ; Set the HTML:
    html.s
    html = "<html><body><p>This is a test.</p><blockquote>Here is text within a blockquote</blockquote></body></html>"

    plainText.s

    plainText = CkHtmlToText::ckToText(h2t,html)

    Debug plainText

    ; The output looks like this:

    ; This is a test.
    ; 
    ;     Here is text within a blockquote


    CkHtmlToText::ckDispose(h2t)


    ProcedureReturn
EndProcedure