Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Parse iTunes XMLDownloads 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.