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

 

 

 

 

 

 

 

SearchForContent

Downloads for Windows/Linux and Install Instructions

Using the SearchForContent method.

# file: xmlSearchForContent.rb
# 
# Using the SearchForContent method...

require 'rubygems'
require 'chilkat'

# The Chilkat XML parser for Ruby is freeware.  The code demonstrated in this
# example can be used in both commercial and non-commercial applications without 
# restriction.  

# The Chilkat XML Ruby examples utilize these online XML data samples:
# http://www.chilkatsoft.com/xml-samples/bookstore.xml
# http://www.chilkatsoft.com/xml-samples/nutrition.xml
# http://www.chilkatsoft.com/xml-samples/pigs.xml
# http://www.chilkatsoft.com/xml-samples/plants.xml
# http://www.chilkatsoft.com/xml-samples/japanese.xml
# http://www.chilkatsoft.com/xml-samples/hamlet.xml
    
xml = Chilkat::CkXml.new()
xml.LoadXmlFile("plants.xml")

# Find the plant having the common name Trillium
botName = Chilkat::CkString.new()
tag = "COMMON"
content = "Trillium"
start = nil
trillium = xml.SearchForContent(start,tag,content)
if (trillium != nil)
	# Move up to the parent node.
	trillium.GetParent2()
	# Print the BOTANICAL name
	trillium.GetChildContent("BOTANICAL",botName)
	print botName.getString() + "\n"
end

print "----\n"

# Find all plants requiring Sunny light.
# Iterate over all <LIGHT>Sunny</LIGHT> nodes in the XML document.
sunny = xml.SearchForContent(nil,"LIGHT","Sunny")
while (sunny != nil)
	# Get the parent.
	plant = sunny.GetParent()
	# Print the BOTANICAL name
	plant.GetChildContent("BOTANICAL",botName)
	print botName.getString() + "\n"
	
	# Get the next plant requiring Sunny light, starting the search after 
	# our current node.
	sunny = xml.SearchForContent(sunny,"LIGHT","Sunny")
end






 

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