我正在尝试使用 PHP 读取 iTunes XML 文件。我想提取特定的信息。例如名称、艺术家和专辑。我该怎么做?我发现它在解析整个文件时效果很好。我想也许用它来创建一个更容易阅读的全新 XML 文件。
但必须有更好的方法。
轨道的 XML 结构如下所示:
<dict>
<key>Track ID</key><integer>6136</integer>
<key>Name</key><string>The Boy Who Destroyed the World</string>
<key>Artist</key><string>AFI</string>
<key>Album Artist</key><string>AFI</string>
<key>Composer</key><string>AFI</string>
<key>Album</key><string>Tony Hawk Pro Skater 3</string>
<key>Genre</key><string>Punk Rock</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>2971924</integer>
<key>Total Time</key><integer>185364</integer>
<key>Track Number</key><integer>3</integer>
<key>Year</key><integer>1999</integer>
<key>Date Modified</key><date>2009-08-20T15:03:20Z</date>
<key>Date Added</key><date>2009-08-20T15:03:20Z</date>
<key>Bit Rate</key><integer>128</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Play Count</key><integer>34</integer>
<key>Play Date</key><integer>3332385360</integer>
<key>Play Date UTC</key><date>2009-08-06T05:36:00Z</date>
<key>Sort Name</key><string>Boy Who Destroyed the World</string>
<key>Persistent ID</key><string>9E590180768D4AD8</string>
<key>Track Type</key><string>File</string>
<key>Location</key><string>FilePath</string>
<key>File Folder Count</key><integer>4</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>