所以我想扫描一个大的 XML 文件(40mb),据我所知,我应该使用 NSXMLParser 来减少内存占用。我想检查每首歌曲的几件事,然后如果它通过所有标准,则将歌曲写入一个新的 xml 文件。
我可以使用 NSXMLParser 加载它并对文件进行一些基本的读取。所以我想知道如何将每首歌曲保存为临时变量?以及应该将其保存为哪种对象(我假设某些东西是可变的,因此我可以在将其写入文件之前继续将更多歌曲添加到文件中)。
<key>Tracks</key>
<dict>
<key>11072</key>
<dict>
<key>Track ID</key><integer>1107</integer>
<key>Name</key><string>Kids with Guns (Hot Chip Remix)</string>
<key>Artist</key><string>Gorillaz</string>
<key>Album</key><string>D-Sides</string>
<key>Genre</key><string>Britpop</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>844299</integer>
<key>Total Time</key><integer>42971</integer>
<key>Disc Number</key><integer>2</integer>
<key>Disc Count</key><integer>2</integer>
<key>Track Number</key><integer>6</integer>
<key>Track Count</key><integer>9</integer>
<key>Year</key><integer>2007</integer>
<key>Date Modified</key><date>2008-10-30T02:44:58Z</date>
<key>Date Added</key><date>2007-12-25T21:54:16Z</date>
<key>Bit Rate</key><integer>153</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Comments</key><string> __FIXED__U74A0ECA</string>
<key>Play Count</key><integer>1</integer>
<key>Play Date</key><integer>3292750639</integer>
<key>Play Date UTC</key><date>2008-05-04T20:57:19Z</date>
<key>Skip Count</key><integer>1</integer>
<key>Skip Date</key><date>2008-02-09T06:17:30Z</date>
<key>Artwork Count</key><integer>2</integer>
<key>Persistent ID</key><string>74A0ECAC8D</string>
<key>Track Type</key><string>File</string>
<key>Location</key><string>file://xxxxx/x/iTunes/Music/Gorillaz/D-Sides/2-06%20Kids%20with%20Guns%20(Hot%20Chip%20Remix).mp3</string>
<key>File Folder Count</key><integer>5</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>