// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.IO.Compression; using System.Net; using System.Web; using System.Xml.Serialization; namespace E { public class Program { public static void Main(string[] args) { string key = "a54c058060"; string artistName = "Dizzy Mizz Lizzy"; string requestUrl = string.Format("http://www.discogs.com/artist/{0}?f=xml&api_key={1}", HttpUtility.UrlEncode(artistName), key); WebClient wc = new WebClient(); wc.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip"); using (GZipStream stream = new GZipStream(wc.OpenRead(requestUrl), CompressionMode.Decompress, false)) { using (StreamReader reader = new StreamReader(stream)) { string str = reader.ReadToEnd(); XmlSerializer serializer = new XmlSerializer(typeof (resp)); resp r = (resp) serializer.Deserialize(new StringReader(str)); foreach(respArtist a in r.artist) { Console.WriteLine("a=" + a.name); foreach(respArtistReleasesRelease ar in a.releases) { Console.WriteLine("ar=" + ar.title); } } } } } } }