title: Extracting information from ITunes Music Library XML with XSLT?
body: <p>I need to extract information from iTunes Music Library.xml file. Since the xml is in the form of plist it has become a bit cumbersome.</p>
  
  <p>I want to get list of all Track IDs from a specific playlist whose "Playlist ID" I have.</p>
  
  <p>For example, An iTunes Playlist looks like below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;Playlists&lt;/key&gt;
      &lt;array&gt;
          &lt;dict&gt;
              &lt;key&gt;Name&lt;/key&gt;&lt;string&gt;Library&lt;/string&gt;
              &lt;key&gt;Master&lt;/key&gt;&lt;true/&gt;
              &lt;key&gt;Playlist ID&lt;/key&gt;&lt;integer&gt;4053&lt;/integer&gt; &lt;!--Ex:4053 I have.--&gt;
              &lt;key&gt;Playlist Items&lt;/key&gt;
              &lt;array&gt;
                  &lt;dict&gt;
                      &lt;key&gt;Track ID&lt;/key&gt;&lt;integer&gt;2413&lt;/integer&gt;
                  &lt;/dict&gt;
                  &lt;dict&gt;
                      &lt;key&gt;Track ID&lt;/key&gt;&lt;integer&gt;2083&lt;/integer&gt;
                  &lt;/dict&gt;
                  &lt;dict&gt;
                      &lt;key&gt;Track ID&lt;/key&gt;&lt;integer&gt;2081&lt;/integer&gt;
                  &lt;/dict&gt;
                  &lt;dict&gt;
                      &lt;key&gt;Track ID&lt;/key&gt;&lt;integer&gt;6798&lt;/integer&gt;
                  &lt;/dict&gt;
                           &lt;/array&gt;
                     &lt;dict&gt;
                     &lt;!-- Here another playlist will start. with diff playlist ID --&gt;
              &lt;array&gt;
  
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>You can check your Itunes Music Library.xml for details.</p>
  
  <p>Basically, What I need is this.
  (a) Given Playlist ID (here 4053), print all the Track Ids values (here: 2413,2083,2081,6798) under that playlist.</p>
  
  <p>My attempt:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:output method="text" /&gt; 
  
  &lt;xsl:template match="/"&gt; 
  
  
  &lt;xsl:for-each select="plist/dict/array/dict"&gt;
  
      &lt;xsl:choose&gt;
          &lt;xsl:when test="child::integer[preceding-sibling::key[1]='Playlist ID']=4053"&gt; 
             &lt;!-- condition is not working fine, Below lines are working fine --&gt;
          &lt;xsl:for-each select="plist/dict/array/dict/array/dict"&gt;
              &lt;xsl:value-of select="child::integer[preceding-sibling::key[1]='Track ID']"/&gt;
              &lt;/xsl:for-each&gt;
          &lt;/xsl:when&gt;
      &lt;/xsl:choose&gt;
  
  
  &lt;/xsl:for-each&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Can any experts on XSLT help me out here. I will be very glad.</p>