C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

Extract Main Headline from CNN Home Page

This example shows how to use the Chilkat HTTP component to fetch the CNN home page, convert it to XML, and then use Chilkat XML to navigate to the main headline and extract it. This example worked on 6-June-2005. Future changes in the HTML delivered by CNN may break this code, but the purpose of the code is to demonstrate the ease of extracting information from HTML.

// Create an instance of Chlkat.Http to fetch the CNN home page.
Chilkat.Http http = new Chilkat.Http();
http.UnlockComponent("HTTP 30-day trial");

// Make our HTTP client mimic Mozilla Firefox
http.MimicFireFox = true;

// Do not fetch from cache or save to cache.
http.FetchFromCache = false;
http.UpdateCache = false;
		
Chilkat.HtmlToXml conv = new Chilkat.HtmlToXml();
conv.UnlockComponent("Html-to-Xml 30-day trial");

// Get the HTML for the CNN home page.		    
conv.Html = http.QuickGetStr("http://www.cnn.com/");

// Convert it to XML and load it into Chilkat XML.
Chilkat.Xml xml = new Chilkat.Xml();
xml.LoadXml(conv.ToXml());

// Navigate to the main headline.
// This works based on the structure of the CNN home page on 6-June-2005.
// This code can break if the HTML returned by CNN changes in certain ways.
// The purpose of this example is to show how easy it is to extract a piece
// of information from an HTML page.
Chilkat.Xml node = xml.SearchForAttribute(null,"div","class","cnnMainT1Hd");
if (node != null) 
{
    node.FirstChild2();
    node.FirstChild2();
    node.FirstChild2();
    MessageBox.Show("Main Headline = " + node.Content);
}


Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 

Need a specific example? Send a request to support@chilkatsoft.com

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

Email Component · XML Parser