Node.js
Node.js
Convert HTML to Plain Text
Demonstrates how to convert HTML to plain text.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var h2t = new chilkat.HtmlToText();
var html = h2t.ReadFileToString("c:/temp/test.html","utf-8");
if (h2t.LastMethodSuccess == false) {
console.log(h2t.LastErrorText);
return;
}
var plainText = h2t.ToText(html);
if (h2t.LastMethodSuccess == false) {
console.log(h2t.LastErrorText);
return;
}
console.log(plainText);
}
chilkatExample();