I have created a web service using ASP.NET and am now creating a client application to consume it.
The service allows the user to create playlist and add songs etc The lists are stored in a XMl file with the following structure:
<?xml version="1.0" encoding="utf-8"?><Playlists><Lists><List ID="3" user="dylan"><Track name="Sorry"><Artist>Justin Bieber</Artist><Album>Purpose</Album><Genre>Pop</Genre></Track><Track name="Thriller"><Artist>Michael Jackson</Artist><Album>Thriller</Album><Genre>Pop</Genre></Track><Track name="Hello"><Artist>Adele</Artist><Album>25</Album><Genre>Pop</Genre></Track></List></Lists></Playlists>
I am looking to extract the various track names, artist, album and genre and display them in a Windows form List Box.
Currently, my code allows me to select a list. However, rather than display the name, artist, album then genre, the list box displays the following (please ignore the data. in this version, I accidentally added 2 instances of Michael Jackson 'Thriller', I'm not that much of a fan! ;) Also, Thriller in this photo is the Album:
I cannot seem to be able to select the "name" attribute.
Any help would be much appreciated. I would like to keep the XML structure the same if possible.
I have posted the code I am using in the client app below.
PublicClassForm1Dim serviceReturn AsStringPrivateSubButton4_Click(sender AsObject, e AsEventArgs)HandlesButton4.ClickDim service AsNewPlaylistReference.ServiceSoapClientTry serviceReturn = service.GetPlaylist(TextBox1.Text)MessageBox.Show(serviceReturn)Catch ex AsExceptionMessageBox.Show("A stock quote for this ticker was not available.")EndTryDim xmlPlaylist AsNewXml.XmlDocument xmlPlaylist.LoadXml(serviceReturn)Dim xmlSong AsXml.XmlNodeForEach xmlSong In xmlPlaylist.DocumentElementDim songName AsString= xmlPlaylist.LastChild.InnerTextListBox1.Items.Add(songName)NextEndSubEndClass
So all that happens is I enter the name of the playlist into TextBox1 and then the press of the button gets the output above. Please ignore the MessageBox function, this is just for testing purposes.