Chapter 13. Access Your iTunes Music Library via XML

 

XML is easy. It is the problems people are trying to address with XML that are hard.

 
 --Jonathan Borden

One problem being addressed with XML is not very hard at all, and is actually quite fun. I’m referring to Apple’s iTunes digital music service, which you probably didn’t realize had anything to do with XML. It turns out that Apple chose XML as the storage format for the library of songs in the iTunes desktop application. The songs themselves are still stored in Apple’s proprietary AAC media format but iTunes keeps track of the songs and pertinent information about them through an XML file. It is this XML file that you focus on in this lesson. More specifically, you learn how to transform your iTunes library so that you can make your song list available on the Web. You even find out how to potentially spin your iTunes song list into a money-making opportunity by providing links to the songs where other people can buy them and earn you a commission from Apple.

In this hour, you’ll learn

  • How XML fits into Apple’s iTunes digital music service

  • About the inner workings of an iTunes music library

  • How to link to tracks in the iTunes music store

  • How to transform your iTunes music library into an HTML web page that you can publish on the Web

The Role of XML in iTunes

Just in case you aren’t familiar with it, iTunes is Apple’s wildly successful online music service, where you can download individual songs in a digital format for around a dollar each. Music downloaded through iTunes is compatible with Apple’s line of iPod music players. If you aren’t familiar with iPod music players, I may not be able to help you! They’ve become quite the cultural phenomenon in terms of bringing digital music to the masses. To learn more about the iTunes service and iPod players, visit http://www.apple.com/itunes/.

By the Way

Digital songs on the iTunes music service are stored in Apple’s AAC (Advanced Audio Codec) format, which is roughly similar to Microsoft’s WMA (Windows Media Audio) format. Both formats are essentially takeoffs on the immensely popular MP3 format that started it all. Apple and Microsoft both added security features to their formats to help prevent piracy.

So what does iTunes have to do with XML? XML enters the picture with iTunes in a couple of different ways. First and foremost, the iTunes desktop application uses XML code as the basis for storing the list of songs, or tracks, in your personal iTunes music library. This XML library code goes beyond just listing the names of the tracks in your library. In fact, it includes information such as the artist, album, genre, and track number on the album (CD) of each track, along with numerous other data fields related to the digitized song file. For example, the XML code includes the bit rate and sample rate of each track, which directly relates to the quality of the music.

Because the iTunes library track listing is stored in XML, you can access it and manipulate it just as you would any other XML document. One neat thing you can do is to transform the XML song list into HTML so that it can be displayed in a web browser. This is exactly what you learn how to do in this hour.

Before you get started accessing your iTunes library, it’s worth mentioning another facet of iTunes that is heavily connected to XML. I’m referring to podcasts, which are digital audio files that typically contain talk shows or other prerecorded themed speech or music. You can think of a podcast as a radio show stored in a file that you can carry with you and listen to whenever you want. Anyone can create his own podcasts and share them with the world via iTunes. After recording and formatting the actual podcast media file, the key to sharing it involves creating an XML document based upon the RSS (Really Simple Syndication) language. You learn how to create news feeds using RSS in Hour 24, “Syndicating the Web with RSS News Feeds.” For now, take a look at what’s available in terms of podcasts by browsing to the Podcasts genre in iTunes. Figure 13.1 shows a podcast highlighted in iTunes.

Podcasts in iTunes are broken down into lots of different categories.

Figure 13.1. Podcasts in iTunes are broken down into lots of different categories.

Unlike normal music tracks that you purchase and download in iTunes, you subscribe to podcasts because they are typically regularly updated with new content. Also, the vast majority of podcasts that you’ll find on iTunes are free. In the figure, the podcast The Dumpster Diving Geek is highlighted—this is a free podcast related to scavenging for high-tech gadgets.

Although podcasting is certainly an interesting subject, it isn’t the primary focus of this lesson. This hour primarily addresses the song library in iTunes, and how to use the fact that it is encoded in XML to share it with the world via the Web.

Digging Into the iTunes Library File

I’ve already mentioned several times that the iTunes library file is stored in an XML format but I haven’t given you any clues regarding how to find or access the file. The file is stored in a different location depending on whether you’re using a Windows or Macintosh computer. Either way, the file is named iTunes Music Library.xml. Following are the locations where you can find the file on each type of computer:

  • Windows— My Documents/My Music/iTunes/iTunes Music Library.xml

  • Mac— Music/iTunes/iTunes Music Library.xml

If, for some reason, you have trouble finding the iTunes XML library file or if you’re just too lazy to drill down into the folders to find it, there is a simpler alternative—just export the file directly from within iTunes. Click File on the main iTunes menu, followed by Export Library. You’ll be given an opportunity to specify the location and filename of the exported XML library file. When you have the library file handy, you can begin studying it and figuring out how to manipulate the XML code for your own needs.

Listing 13.1 contains an excerpt from an iTunes library file. Keep in mind that there is a lot more information in the library file that I’ve left out. The emphasis for this lesson is on extracting XML data pertaining to the tracks referenced in the library, so the listing only shows the XML code for a single track.

Example 13.1. The XML Code for a Single Track Within an iTunes Library File

 1: <dict>
 2:   <key>Track ID</key><integer>35</integer>
 3:   <key>Name</key><string>Landslide</string>
 4:   <key>Artist</key><string>Fleetwood Mac</string>
 5:   <key>Album</key><string>The Dance</string>
 6:   <key>Genre</key><string>Rock</string>
 7:   <key>Kind</key><string>Protected AAC audio file</string>
 8:   <key>Size</key><integer>4285488</integer>
 9:   <key>Total Time</key><integer>268283</integer>
10:   <key>Disc Number</key><integer>1</integer>
11:   <key>Disc Count</key><integer>1</integer>
12:   <key>Track Number</key><integer>9</integer>
13:   <key>Track Count</key><integer>17</integer>
14:   <key>Year</key><integer>1997</integer>
15:   <key>Bit Rate</key><integer>128</integer>
16:   <key>Sample Rate</key><integer>44100</integer>
17: </dict>s

Based upon what you’ve learned throughout the book thus far, you’ve probably already realized that this isn’t your average run-of-the-mill XML code. In fact, Apple deviated considerably from traditional XML design sense by structuring the iTunes library file as pairs of key values instead of more meaningful XML tags. In other words, just about everything in an iTunes library is stored as a key with a corresponding value. As an example, the artist for the track is coded using a <key> tag with Artist as its content (line 4). Immediately following this <key> tag is a corresponding <string> tag that holds the name of the artist associated with the key; in this case, Fleetwood Mac.

You can continue examining the code in the listing to see how other information about the track is coded using key values. The key-value pairings always consist of a <key> tag followed by a tag that indicates the type of the data stored, such as <string> or <integer>. An example of an integer key-value is the track number, which is the number of the track on the actual album or CD (line 12). In this example, the song “Landslide” is track number 9 on the CD The Dance by Fleetwood Mac.

By the Way

There is a DTD available from Apple for validating iTunes music library files. You can access the DTD online at http://www.apple.com/DTDs/PropertyList-1.0.dtd.

Taking a step back for a moment, it’s worth noting that the key-value information for a track occurs within a dict element. dict stands for dictionary, which simply refers to a data structure consisting of keys and values. A complete library file consists of multiple nested dict elements that are used to store various pieces of information related to the library, such as the list of tracks in the library along with any playlists. Because you’re only concerned at the moment with extracting and viewing the library of songs, it isn’t necessary to deal with playlist data.

You now have some idea regarding the structure of the iTunes library file but there is another topic worth addressing before you start ripping through the XML code to generate a view of it that is browser friendly. I’m referring to the creation of links to the iTunes music store.

Linking to Tracks in the iTunes Store

Although it would certainly still be an interesting example if I just showed you how to transform the iTunes music library into a format that can be shared and viewed on the Web, that doesn’t serve enough of a practical purpose. It doesn’t do you much good to share your music library with others unless they have a means of accessing tracks within the library and playing or purchasing the tracks themselves. For this reason, it’s important to include links back to the iTunes music store for all of the tracks in your music library. And if you sign up to become an iTunes affiliate, you can even earn commissions on other people buying songs from your music list.

The trick to tying your music library to the iTunes music store involves being able to generate links to individual tracks within the store. These links vary a little based upon whether or not you are an iTunes affiliate attempting to earn commissions or if you just want to provide a link without any financial angle. I’m going to assume the latter because becoming an iTunes affiliate is somewhat of another topic.

By the Way

To learn more about becoming an iTunes affiliate, visit the iTunes Affiliates web site at http://www.apple.com/itunes/affiliates/.

There are essentially three different kinds of links you’re going to focus on in regard to the iTunes music store and your music library:

  • Link to a track (song)

  • Link to an album (CD)

  • Link to an artist

As you can see, these types of links are increasingly more general as you go from track to album to artist. The idea is that you can give visitors to your music library page the option of looking up a specific song on iTunes or browsing more generally based upon the album or the artist.

Every link to the iTunes music store begins with a common base search URL:

itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?

When entered by itself as you see it here, this link will simply launch iTunes and lead you to the main iTunes search page, as shown in Figure 13.2.

The base search URL for iTunes leads you to the main iTunes search page.

Figure 13.2. The base search URL for iTunes leads you to the main iTunes search page.

The figure should give you a clue as to how you’re going to build links into the iTunes music store. By appending search fields onto the base URL, you are effectively initiating an iTunes search via a URL. There are three main search parameters you’re interested in when it comes to initiating such a search:

  • songTerm— Search for a song (track)

  • albumTerm— Search for an album (CD)

  • artistTerm— Search for an artist

You can use any combination of these search parameters to come up with a specific search URL that hones in on matching iTunes music. For example, to search for a specific song by a specific artist that appears on a specific album, you’ll want to specify all three parameters. Following is an example of such a URL:

itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?songTerm=
Hoist That Rag&albumTerm=Real Gone&artistTerm=Tom Waits

By the Way

Keep in mind that in XML code you must convert ampersand (&) characters to the &amp; character entity.

In this example, the song “Hoist That Rag” on the album Real Gone by Tom Waits is searched on iTunes. The resulting song as found in iTunes appears in Figure 13.3.

An iTunes search URL for a specific song results in the song being selected in iTunes.

Figure 13.3. An iTunes search URL for a specific song results in the song being selected in iTunes.

Of course, you can be more general if you want a search to focus on an individual album or artist, as opposed to a specific song. Following is a URL that searches for the artist Trashcan Sinatras.

itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?
artistTerm=Trashcan Sinatras

Just in case you’ve been following along without actually trying any of the examples, please feel free to enter some of these URLs into a real web browser to try them out. Also make sure to try altering the URLs to search for some music of your own. Of course, you’ll need to have iTunes installed in order for any of the search URLs to work.

Building an iTunes Web Viewer

You now have some basic knowledge of the iTunes XML library file along with how to build links to tracks, albums, and artists within the iTunes music store. You’re ready to pull everything together into a practical example that allows you to publish your iTunes music library online, complete with links that allow people to listen to samples, buy the tracks, and browse the albums and artists.

Revisiting the iTunes XML Music Library

You’re going to create an XSLT stylesheet that transforms your iTunes XML library document into an HTML document that is suitable for viewing in a web browser. But before you get into the code for the stylesheet, let’s take one more look at the XML code for a library file. Listing 13.2 contains partial code for an iTunes library file where the code for a music track is visible.

Example 13.2. A Partial Listing of an iTunes Music Library.xml Music Library Document

 1: <?xml version="1.0" encoding="UTF-8"?>
 2: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/
 3:   PropertyList-: 1.0.dtd">
 4: <?xml-stylesheet href="itunesview.xsl" type="text/xsl"?>
 5: <plist version="1.0">
 6: <dict>
 7:   <key>Major Version</key><integer>1</integer>
 8:   <key>Minor Version</key><integer>1</integer>
 9:   <key>Application Version</key><string>4.9</string>
10:   <key>Music Folder</key><string>file://localhost/C:/Documents%20and%20Settings/
11:   Michael%20Morrison/My%20Documents/My%20Music/iTunes/iTunes%20Music/
12:   </string>
13:   <key>Library Persistent ID</key><string>45B7F87C7466C64A</string>
14:   <key>Tracks</key>
15:   <dict>
16:     ...
17:     <key>37</key>
18:     <dict>
19:       <key>Track ID</key><integer>37</integer>
20:       <key>Name</key><string>Thinking Of You</string>
21:       <key>Artist</key><string>Lenny Kravitz</string>
22:       <key>Composer</key><string>Lenny Kravitz/Lysa Trenier</string>
23:       <key>Album</key><string>5</string>
24:       <key>Genre</key><string>Pop/Funk</string>
25:       <key>Kind</key><string>MPEG audio file</string>
26:       <key>Size</key><integer>6141310</integer>
27:       <key>Total Time</key><integer>383764</integer>
28:       <key>Track Number</key><integer>32</integer>
29:       <key>Year</key><integer>1998</integer>
30:       <key>Date Modified</key><date>2005-06-08T20:04:06Z</date>
31:       <key>Date Added</key><date>2004-05-06T04:29:57Z</date>
32:       <key>Bit Rate</key><integer>128</integer>
33:       <key>Sample Rate</key><integer>44100</integer>
34:       <key>Comments</key><string>By ScazzI</string>
35:       <key>Play Count</key><integer>6</integer>
36:       <key>Play Date</key><integer>-1088231274</integer>
37:       <key>Play Date UTC</key><date>2005-08-13T05:00:22Z</date>
38:       <key>Track Type</key><string>File</string>
39:       <key>Location</key><string>file://localhost/C:/
40:       Documents%20and%20Settings/Michael%20Morrison/My%20Documents/
41:       My%20Music/Masheed/Lenny%20Kravitz%20-%20Thinking%20Of%20You.mp3/
42:       </string>
43:       <key>File Folder Count</key><integer>-1</integer>
44:       <key>Library Folder Count</key><integer>-1</integer>
45:     </dict>
46:     ...
47: </dict>
48: </plist>

This XML-coded iTunes music track contains all the information you need to crank out an XSLT stylesheet that rips out the important information and transforms it into something pretty that can be viewed in a web browser. Just in case you aren’t seeing it right off, lines 18 through 45 contain the key-value pairings for the song “Thinking Of You” by Lenny Kravitz.

Because stylesheets aren’t magically associated with XML documents automatically, you must make a small addition to your XML music library document in order to wire it to the XSLT stylesheet that you’re about to see. This line of code is already present in the XML library document shown in Listing 13.2. Just check out line 4 to see how the familiar xml-stylesheet directive is used to link the stylesheet to the XML document. Make sure to add this line of code to your own XML library document or the stylesheet will have no effect.

Inside the iTunes Viewer XSLT Stylesheet

The stylesheet that transforms the iTunes music library document is really only interested in three pieces of information in the document: the track name, artist, and album. This information is relatively easy to find within the document because the <key> tag contains the text Name, Artist, and Album for each piece of information, respectively. Therefore, the job of the stylesheet is to look through the XML code for tags whose content is equal to Name, Artist, or Album, and then grab the contents of the adjacent “value” tag (<string> in this case).

Listing 13.3 contains the complete code for the itunesview.xsl_XSLT stylesheet, which transforms the tracks in an iTunes music library document into a nicely formatted list complete with links back to the iTunes music store.

Example 13.3. The itunesview.xsl XSLT Stylesheet Transforms an iTunes Music Library into a Cleanly Formatted HTML Web Page

  1: <?xml version="1.0"?>
  2: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3:   <xsl:template match="/">
  4:     <html><head><title>My iTunes Songs</title></head>
  5:     <style>
  6:       <xsl:comment>
  7:       h1 {
  8:         text-align:center;
  9:         font-family:arial;
 10:         font-size:18pt;
 11:         color:#669966;
 12:       }
 13:       table {
 14:         border-style:none;
 15:         padding:0px;
 16:         margin:0px;
 17:         text-align:left;
 18:       }
 19:       th {
 20:         font-family:arial;
 21:         font-size:14pt;
 22:         background-color:#669966;
 23:         color:#FFFFFF;
 24:       }
 25:
 26:       td {
 27:         font-family:arial;
 28:         font-size:11pt;
 29:         color:#669966;
 30:       }
 31:
 32:       a:link {
 33:         text-decoration:none;
 34:         color:#669966;
 35:       }
 36:
 37:       a:hover {
 38:         font-weight:bold;
 39:         text-decoration:none;
 40:         color:#66BB66;
 41:       }
 42:
 43:       a:visited {
 44:         text-decoration:none;
 45:         color:#333333;
 46:       }
 47:       </xsl:comment>
 48:     </style>
 49:
 50:     <body>
 51:       <h1>My iTunes Songs</h1>
 52:       <table style="width:100%">
 53:         <tr style="font-weight:bold">
 54:           <th style="width:40%">Name</th>
 55:           <th style="width:20%">Artist</th>
 56:           <th style="width:40%">Album</th>
 57:         </tr>
 58:         <xsl:call-template name="main" />
 59:       </table>
 60:     </body>
 61:     </html>
 62:   </xsl:template>
 63:
 64:   <xsl:template name="main">
 65:     <xsl:for-each select="/*/*/dict[1]/dict">
 66:       <xsl:element name="tr">
 67:         <xsl:call-template name="song" />
 68:       </xsl:element>
 69:     </xsl:for-each>
 70:   </xsl:template>
 71:
 72:   <xsl:template name="song">
 73:     <tr>
 74:       <xsl:if test="position() mod 2 != 1">
 75:         <xsl:attribute name="style">background-color:#EEEEEE
 76:         </xsl:attribute>
 77:       </xsl:if>
 78:
 79:       <td style="height=20px">
 80:         <xsl:element name="a">
 81:           <xsl:attribute name="href">
 82:             itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/
 83:             advancedSearchResults?songTerm=<xsl:value-of select=
 84:             "child::*[preceding-sibling::* = 'Name']" />&amp;artistTerm=
 85:             <xsl:value-of select="child::*[preceding-sibling::* =
 86:             'Artist']" />&amp;albumTerm=<xsl:value-of select=
 87:             "child::*[preceding-sibling::* = 'Album']" />
 88:           </xsl:attribute>
 89:           <img src="itunes.gif" alt="iTunes" style="border:none" />
 90:           <xsl:text> </xsl:text><xsl:value-of select=
 91:           "child::*[preceding-sibling::* = 'Name']" />
 92:         </xsl:element>
 93:       </td>
 94:
 95:       <td>
 96:         <xsl:element name="a">
 97:           <xsl:attribute name="href">
 98:             itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/
 99:             advancedSearchResults?artistTerm=<xsl:value-of select=
100:             "child::*[preceding-sibling::* = 'Artist']" />
101:           </xsl:attribute>
102:           <xsl:value-of select="child::*[preceding-sibling::* =
103:           'Artist']" />
104:         </xsl:element>
105:       </td>
106:
107:       <td>
108:         <xsl:element name="a">
109:           <xsl:attribute name="href">
110:             itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/
111:             advancedSearchResults?artistTerm=<xsl:value-of select=
112:             "child::*[preceding-sibling::* = 'Artist']" />&amp;albumTerm=
113:             <xsl:value-of select="child::*[preceding-sibling::* =
114:             'Album']" />
115:           </xsl:attribute>
116:           <xsl:value-of select="child::*[preceding-sibling::* =
117:           'Album']" />
118:         </xsl:element>
119:       </td>
120:     </tr>
121:   </xsl:template>
122: </xsl:stylesheet>

I realize this is a pretty hefty listing but don’t let it intimidate you. If you take a closer look at the code, you’ll realize that almost the first half of it is an internal CSS stylesheet aimed at making the resulting HTML document more visually appealing. In other words, there is nothing critical in lines 5 through 48 that would prevent the XSLT stylesheet from working if you deleted those lines. However, the internal CSS stylesheet is still useful in that it formats and styles the output so that it is easier to view.

The real meat of the XSLT stylesheet begins on line 72 where the song template begins. This template is initiated from line 67 within the main template upon finding nested <dict> tags. If you refer back to Listing 13.2 (lines 15 through 18), you’ll notice that songs in the music library are coded within <dict> tags (one for each song) that are nested within a higher level <dict> tag. The main template in the stylesheet uses this relationship as the basis for determining if it has encountered song data. If so, the song template is called to further process the song data.

The song template comprises the remainder of the stylesheet. It starts off by performing a sneaky little trick to draw an alternating background color for each song (lines 74 to 77). This gives the resulting page a horizontally striped appearance that helps you distinguish each song from the next. To alternate the background color for each song, the position() function is called to determine the position of the current node. The specific value that this function returns isn’t really important so long as it serves as a counter as you progress through the songs. The mod operator that is applied to the return value of the position() function results in a different background color being applied for evenly numbered rows of song data.

After the background color trick, the song template moves on to laying out the cell data for the three table cells (song, artist, and album) that represent a song row in the HTML table. The first cell is the song cell, and it consists of the song name coded as an anchor link that links to the song in the iTunes music store. Lines 80 through 92 reveal how the <a> tag is coded for the song link, including the dynamically assembled href attribute (lines 81 through 88), an iTunes logo image (line 89), and the actual song name itself (lines 90 and 91). The remaining code in the song template carries out a similar task for the artist and album cells within the table.

Viewing the End Result in a Browser

You’re finally ready to see the end result of all your hard work. Just open your music library XML document in a web browser to view it transformed as an HTML web page. Figure 13.4 shows a sample iTunes library as viewed in Internet Explorer.

This iTunes music library has been successfully transformed thanks to the itunesview.xsl XSLT stylesheet.

Figure 13.4. This iTunes music library has been successfully transformed thanks to the itunesview.xsl XSLT stylesheet.

By the Way

If for some reason your iTunes music library isn’t styled when you open it in a web browser, check to make sure that you’ve added the line of code that links the itunesview.xsl stylesheet to the XML document (see line 4 of Listing 13.2).

As the figure reveals, all of the tracks in the iTunes XML library document are transformed into a cleanly formatted web page that is easy to read. Perhaps even more interesting is how the songs, artists, and albums all serve as links to relevant areas of the iTunes music store. By clicking any of these links you are led directly to the song, artist, or album in the music store. Figure 13.5 shows the iTunes application after clicking the song Sissyneck in Figure 13.4.

Clicking a song on the transformed web page takes you to the song in the iTunes music store.

Figure 13.5. Clicking a song on the transformed web page takes you to the song in the iTunes music store.

As promised, clicking the song in the music library web page leads straight to the song in the music library within the iTunes application. So, if this page is published on the Web, anyone who visits it and clicks a link will be led to the appropriate search result within her own iTunes desktop application, which is where the music store is located.

Summary

This lesson took a dramatic turn toward the practical and the entertaining by showing you how XML is used in an extremely popular real-world application. More specifically, you learned how an iTunes music library is coded as an XML document that can be manipulated without too much difficulty. You worked through the specific XML format used by iTunes as well how to create an XSLT stylesheet that drills into that format and extracts information about individual tracks. This hour even showed you how to construct hyperlinks to the iTunes music store so that you can provide links between your music library and iTunes for people to buy the songs listed in your library. All of this learning culminated in a complete example that allows you to make your iTunes music library available on the Web for other people to view and use as a basis for shopping for iTunes music.

Q&A

Q.

Can I use any version of iTunes to access the music library as XML?

A.

No. Early versions of iTunes stored the music library as specially formatted text without XML tags. Your best bet is to download the latest version of iTunes from Apple at http://www.apple.com/itunes/download/.

Q.

Can I use what I learned in this hour about iTunes and XML to create podcasts?

A.

Not exactly. Although iTunes podcasts do rely on XML in order to be published properly, they use a different XML format that is based on RSS (Really Simple Syndication). So, there is really no correlation between the XML code used to store an iTunes music library and the XML code used to syndicate a podcast. RSS is discussed in detail in Hour 24.

Q.

How do I keep my music library current if I want to publish it on the Web?

A.

Because the itunesview.xsl stylesheet is entirely external, all you must do to update your music library online is to grab (copy or export) the latest XML music library file from iTunes and paste in the line of code that links the stylesheet to it. Publish this file over the previous version and your library is updated and ready to roll!

Workshop

The Workshop is designed to help you anticipate possible questions, review what you’ve learned, and begin learning how to put your knowledge into practice.

Quiz

1.

What XML markup language does iTunes use to store its music library?

2.

What is the purpose of the <key> tag in an iTunes music library?

3.

What three search parameters are used to build link URLs into the iTunes music store?

Quiz Answers

1.

Okay, this was a bit of a trick question. The iTunes music library XML format isn’t based on any specific XML markup language. Instead, it uses somewhat of a generic dictionary format that maps keys to values. The DTD for the format is available online at http://www.apple.com/DTDs/PropertyList-1.0.dtd.

2.

The iTunes music library format is based on key-value pairs of data where a key identifies the name of the data and a subsequent type tag contains the data itself. The <key> tag marks up the name of the data in this pairing.

3.

The three search parameters used to build link URLs into the iTunes music store are songTerm, albumTerm, and artistTerm.

Exercises

1.

Add the line of code to link the iTunes viewer stylesheet to your own iTunes music library XML document. Open the document in a browser and experiment with the links.

2.

Visit http://www.apple.com/itunes/affiliates/ and consider becoming an iTunes affiliate so that you can publish your music library online and maybe earn some commissions off of your excellent taste in music. Make sure to change the link code in the stylesheet to include your affiliate ID so that you’ll actually get commission credit when someone buys a song after following a link from your music library.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.232.189