Hey guys, first time post. I'm relatively new with Processing so excuse me if I make stupid mistakes
I've imported data from my iTunes xml data file. I only needed the genre of each song, plus the amount of times I've played that song. So far I'm able to print the information correctly in the console, but I'm a bit stuck for the next phase.
I want to collect the amount of times a song has been played for each genre. For example, if I have three songs that have the genre of "Classic Rock" and have a playcount of 5, 3, and 1 respectively, how can I get Processing to recognize a specific genre and then add up data only relating to that specific genre? I'd assume everything would be stored in an integer variable, but I'm stuck.
Here's my code so far:
XMLElement xml;
void setup() {
size(200, 200);
xml = new XMLElement(this, "iTunesMusicLibrary.xml");
XMLElement[] songData = xml.getChildren("dict/dict/dict");
for (int i=0; i < songData.length; i++) {
for (int j=0; j < songData[i].getChildCount(); j+=2 ) {
XMLElement key = songData[i].getChild(j);
XMLElement value = songData[i].getChild(j+1);
if (key.getContent().equals("Genre") ) {
println("Genre: " + value.getContent() );
}
if (key.getContent().equals("Play Count") ) {
println("Play Count: " + value.getContent() );
}
}
}
}