Ruby
Ruby
Convert HTML to Plain Text
Demonstrates how to convert HTML to plain text.Chilkat Ruby Downloads
require 'chilkat'
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
h2t = Chilkat::CkHtmlToText.new()
html = h2t.readFileToString("c:/temp/test.html","utf-8")
if (h2t.get_LastMethodSuccess() == false)
print h2t.lastErrorText() + "\n";
exit
end
plainText = h2t.toText(html)
if (h2t.get_LastMethodSuccess() == false)
print h2t.lastErrorText() + "\n";
exit
end
print plainText + "\n";