public Playlist createItemFromElement(DomElement element) { Playlist playlist = new Playlist(); if (element.hasChild("id")) playlist.id = Integer.parseInt(element.getChildText("id")); playlist.title = element.getChildText("title"); if (element.hasChild("size")) playlist.size = Integer.parseInt(element.getChildText("size")); playlist.creator = element.getChildText("creator"); playlist.annotation = element.getChildText("annotation"); DomElement trackList = element.getChild("trackList"); if (trackList != null) { for (DomElement te : trackList.getChildren("track")) { Track t = new Track( te.getChildText("title"), te.getChildText("identifier"), te.getChildText("creator")); t.album = te.getChildText("album"); t.duration = Integer.parseInt(te.getChildText("duration")) / 1000; t.imageUrls.put(ImageSize.LARGE, te.getChildText("image")); t.imageUrls.put(ImageSize.ORIGINAL, te.getChildText("image")); t.location = te.getChildText("location"); for (DomElement ext : te.getChildren("extension")) { if ("http://www.last.fm".equals(ext.getAttribute("application"))) { for (DomElement child : ext.getChildren()) { t.lastFmExtensionInfos.put(child.getTagName(), child.getText()); } } } playlist.tracks.add(t); } if (playlist.size == 0) playlist.size = playlist.tracks.size(); } return playlist; }