Java Examples

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

Java Examples

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

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

 

 

 

 

 

 

 

Drop Specific HTML Tags during Conversion

 Chilkat Java Library Downloads for Windows, Linux, and MAC OS X

The Html-to-Xml converter can be told to drop specific HTML tags during the conversion process. This is done by calling DropTagType for each tag to be dropped.

Download Java Programming Examples

// Drop specific HTML tags during the HTML-to-XML conversion process.
	
import com.chilkatsoft.CkHtmlToXml;
import com.chilkatsoft.CkByteData;
import com.chilkatsoft.CkString;

public class HtmlDropTags {
	
  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }
  
// Demonstrates how to drop specific tags during the HTML-to-XML conversion.

  public static void main(String argv[]) 
  {
    CkHtmlToXml htmlConv = new CkHtmlToXml();
    htmlConv.UnlockComponent("anything for 30-day trial");
    
	String html = "<html><body><span>This <b>is</b> a <i>test</i><hr></span></body></html>";
	
	// First, call UndropTextFormattingTags to prevent the text formatting tags
	// from being dropped by default.
	htmlConv.UndropTextFormattingTags();

	// We'll want to drop <hr>, <i>, and <span> tags:
	htmlConv.DropTagType("hr");
	htmlConv.DropTagType("i");
	htmlConv.DropTagType("span");
	
	// To convert, set the HTML and get the XML:
	htmlConv.put_Html(html);
	String xml = htmlConv.xml();
	
	System.out.println(xml);
	
	/*
		The output is this:
		
		<?xml version="1.0" encoding="utf-8" ?>

		<root>
		    <html>
		        <body>
		            <text>This </text>
		            <b>
		                <text>is</text>
		            </b>
		            <text>a  test</text>
		        </body>
		    </html>
		</root>	
				
		*/
			
  }
}


 

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