public string GetArtistThumbnail(string artistName) { var request = WebRequest.Create('http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=' + artistName + '&api_key=' + APIKey) as HttpWebRequest; using (var response = request.GetResponse() as HttpWebResponse) { var ds = new DataSet(); ds.ReadXml(response.GetResponseStream()); // <-- Exception is thrown here } return ''; }
The above method basically retrieves an xml file from one of LastFM’s API Services.
Now, I am facing the following exception when filling the dataset from the xml with the ReadXml method:
The table (artist) cannot be the child table to itself in nested relations.
Here is an example of an XML file that is being retrieved
Notice that there is a nested Artist in the XML file, and I obviously presume that that is the reason for the exception.
My question, how can I prevent this from happening? as regards the nested tables
As far as I know, DataSets aren’t meant to hold just about any type of XML. Do you really need a dataset in this case?
I suggest switching to linq 2 xml or XmlDocument to manipulate the results of the web service.