Sample code for 30+ languages & platforms
Unicode C

Convert HTML to Plain Text

Demonstrates how to convert HTML to plain text.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHtmlToTextW.h>

void ChilkatSample(void)
    {
    HCkHtmlToTextW h2t;
    const wchar_t *html;
    const wchar_t *plainText;

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

    h2t = CkHtmlToTextW_Create();

    html = CkHtmlToTextW_readFileToString(h2t,L"c:/temp/test.html",L"utf-8");
    if (CkHtmlToTextW_getLastMethodSuccess(h2t) == FALSE) {
        wprintf(L"%s\n",CkHtmlToTextW_lastErrorText(h2t));
        CkHtmlToTextW_Dispose(h2t);
        return;
    }

    plainText = CkHtmlToTextW_toText(h2t,html);
    if (CkHtmlToTextW_getLastMethodSuccess(h2t) == FALSE) {
        wprintf(L"%s\n",CkHtmlToTextW_lastErrorText(h2t));
        CkHtmlToTextW_Dispose(h2t);
        return;
    }

    wprintf(L"%s\n",plainText);


    CkHtmlToTextW_Dispose(h2t);

    }