Transform Your iTunes Library File

Grab data out of your iTunes library file and transform it into HTML.

Apple’s iTunes ( is a nifty application that allows you to purchase, store, organize, and play media on either the Mac or Windows. You can buy and download individual songs or whole albums from the iTunes Music Store, and then store them on your hard drive, burn them to CD, or load them into an iPod digital music player ( Figure 3-22 shows the iTunes Music Store in the iTunes application in Windows.

iTunes Music Store

Figure 3-22. iTunes Music Store

One XML feature of iTunes is that you can save information about your music library in an XML file using the File Export Library command. This file is an example of the Apple Property List (plist) file format, common on Mac OS X systems. For example, the file ~/.MacOSX/environment.plist is a plist file in which a user’s environment variables are stored and that can be edited with the (see for an example).

In raw form, plist files can be long and hard to decipher. That’s where XSLT can help. This hack will show you how to transform your Library.xml plist file into HTML. A few lines of an instance of Library.xml (Version are shown in Example 3-26.

Example 3-26. Library.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...

Get XML Hacks now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.