Sample code for 30+ languages & platforms
C

Convert HTML to Plain Text

Demonstrates how to convert HTML to plain text.

Chilkat C Downloads

C
#include <C_CkHtmlToText.h>

void ChilkatSample(void)
    {
    HCkHtmlToText h2t;
    const char *html;
    const char *plainText;

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

    h2t = CkHtmlToText_Create();

    html = CkHtmlToText_readFileToString(h2t,"c:/temp/test.html","utf-8");
    if (CkHtmlToText_getLastMethodSuccess(h2t) == FALSE) {
        printf("%s\n",CkHtmlToText_lastErrorText(h2t));
        CkHtmlToText_Dispose(h2t);
        return;
    }

    plainText = CkHtmlToText_toText(h2t,html);
    if (CkHtmlToText_getLastMethodSuccess(h2t) == FALSE) {
        printf("%s\n",CkHtmlToText_lastErrorText(h2t));
        CkHtmlToText_Dispose(h2t);
        return;
    }

    printf("%s\n",plainText);


    CkHtmlToText_Dispose(h2t);

    }