public void AddSimilarArtist(SimilarArtist artist) { similar_artists.Add (artist); }
private Artist ParseSimilar(string content) { XmlDocument xml = new XmlDocument (); XmlNodeList elemlist; xml.LoadXml (content); elemlist = xml.GetElementsByTagName ("similarartists"); if (elemlist.Count == 0) { return null; } XmlNode artist_node = elemlist[0]; Artist artist = new Artist (); artist.Name = artist_node.Attributes.GetNamedItem ("artist").InnerText; artist.Streamable = (artist_node.Attributes.GetNamedItem ("streamable").InnerText == "1"); artist.ImageUrl = artist_node.Attributes.GetNamedItem ("picture").InnerText; artist.Mbid = artist_node.Attributes.GetNamedItem ("mbid").InnerText; elemlist = xml.GetElementsByTagName ("artist"); // Loop over all the artists adding them as // similar artists IEnumerator ienum = elemlist.GetEnumerator (); while (ienum.MoveNext ()) { XmlNode a_node = (XmlNode) ienum.Current; SimilarArtist similar = new SimilarArtist (); similar.Name = get_node_text (a_node, "name"); similar.Streamable = (get_node_text (a_node, "streamable") == "0"); similar.Mbid = get_node_text (a_node, "mbid"); similar.Url = get_node_text (a_node, "url"); CultureInfo match_fmt = new CultureInfo("", false); similar.Relevance = Decimal.ToInt32(Decimal.Parse (get_node_text (a_node, "match"), match_fmt)); artist.AddSimilarArtist (similar); } return artist; }