Ruby Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Ruby
Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SFTP
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA
LZW

 

 

 

 

 

 

 

Dropping/Undropping HTML Text Formatting Tags

Downloads for Windows/Linux and Install Instructions

Ruby example to demonstrate how text formatting tags (b, font, i, u, br, center, em, strong, big, tt, s, small, strike, sub, and sup) are dropped by default. The UndropTextFormattingTags method prevents the formatting tags from being dropped during conversion.

# file: TextFormattingTags.rb

require 'rubygems'
require 'chilkat'

# Demonstrates how HTML text formatting tags are (by default) dropped
# during the HTML to XML conversion process.  To keep text formatting
# tags, call UndropTextFormattingTags

htmlConv = Chilkat::CkHtmlToXml.new()
success = htmlConv.UnlockComponent("anything for 30-day trial")
if not success
	print "component is locked!"
	exit
end

html = "<html><body>This <b>is</b> a <i>test</i></body></html>"
	
# To convert, set the HTML and get the XML:
htmlConv.put_Html(html)
xml = htmlConv.xml()
	
print xml


#		The output is this:
#		
#		<?xml version="1.0" encoding="utf-8" ?>
#
#		<root>
#		    <html>
#		        <body>
#		            <text>This  is a  test</text>
#		        </body>
#		    </html>
#		</root>
#		
#		
			
# What happened to the <b> and <i> tags???
# By default, text formatting tags are dropped.
# If we call UndropTextFormattingTags, the tags will remain:
htmlConv.UndropTextFormattingTags()
	
xml = htmlConv.xml()

print xml
	
#		We now get this:
#		
#		<?xml version="1.0" encoding="utf-8" ?>
#
#		<root>
#		    <html>
#		        <body>
#		            <text>This </text>
#		            <b>
#		                <text>is</text>
#		            </b>
#		            <text>a </text>
#		            <i>
#		                <text>test</text>
#		            </i>
#		        </body>
#		    </html>
#		</root>
			



 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.