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

 

 

 

 

 

 

 

Parse iTunes XML

Downloads for Windows/Linux and Install Instructions

Ruby sample code to parse an iTunes XML file. On a Windows computer, you'll find the iTunex XML file in My Documents\My Music\iTunes\.

# file: parseItunesXml.rb
# 
# Ruby script to parse an iTunes XML document

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.  

xml = Chilkat::CkXml.new()
xml.LoadXmlFile("c:/temp/itunes.xml")

# Search for this node: <key>Tracks</key>
tracksKey = xml.SearchForContent(xml,"key","Tracks")

# Assuming it's found, the <dict> node is the next sibling
dict = tracksKey.NextSibling()

# Loop over the <dict> child nodes...
n = dict.NumChildrenHavingTag("dict")
for i in 0..(n-1)
	trackRec = dict.GetNthChildWithTag("dict",i)
	print "Name: " + trackRec.GetChildExact("key","Name").NextSibling().content + "\n"
	print "Artist: " + trackRec.GetChildExact("key","Artist").NextSibling().content + "\n"
	print "Time: " + trackRec.GetChildExact("key","Total Time").NextSibling().content + "\n"
end






 

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