public static Track getTrackFromXml(XmlTag trackTag) {
    if (trackTag == null) {
      return null;
    }

    String id = trackTag.getChildByNameValue("id");
    String name = trackTag.getChildByNameValue("name");
    if (name != null) name = Html.fromHtml(name).toString();
    String mbid = trackTag.getChildByNameValue("mbid");
    String url = trackTag.getChildByNameValue("url");
    boolean streamable = "1".equals(trackTag.getChildByNameValue("streamable")) ? true : false;
    int trackNumber = 0;
    int duration = 0;
    int listeners = 0;
    int playcount = 0;
    try {
      trackNumber = Integer.parseInt(trackTag.getAttribute("rank"));
      duration = Integer.parseInt(trackTag.getChildByNameValue("duration"));
      listeners = Integer.parseInt(trackTag.getChildByNameValue("listeners"));
      playcount = Integer.parseInt(trackTag.getChildByNameValue("playcount"));
    } catch (NumberFormatException e) {
    } catch (NullPointerException e) {
    }

    Artist artist = getSimilarArtistFromXml(trackTag.getChildByName("artist"));
    Album album = getAlbumFromXml(trackTag.getChildByName("album"));
    List<Tag> tags = getTagsFromXml(trackTag.getChildByName("toptags"));
    Map<String, Object> wiki = getWikiTextFromXml(trackTag.getChildByName("wiki"));

    Date published = null;
    String summary = null;
    String content = null;

    if (wiki != null) {
      published = (Date) wiki.get("published");
      summary = (String) wiki.get("summary");
      content = (String) wiki.get("content");
    }

    Track track = new Track(name, url);
    track.setId(id);
    track.setMbid(mbid);
    track.setStreamable(streamable);
    track.setTrackNumber(trackNumber);
    track.setDuration(duration);
    track.setListeners(listeners);
    track.setPlaycount(playcount);
    track.setArtist(artist);
    track.setAlbum(album);
    track.setTags(tags);
    track.setPublished(published);
    track.setSummary(summary);
    track.setContent(content);

    return track;
  }