Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

Help with XML in visual basic.

$
0
0
Hey people. I'm making a program that uses Spotify's Web API to search for music, it gives everything in a XML file, that looks like this (a search for a song called ho hey) http://ws.spotify.com/search/1/track?q=Ho+Hey

The problem I'm having is to get the track names, album info and artist info.
This is the code I got so far, or the function for searching.
(some msgboxes are made for testing, so don't mind those)

Public Function Search(ByVal Songname As String, ByVal mode As Integer)
TextBox1.Text = Songname
Dim url As String
Dim reader As XDocument
If Songname = ("") Then
Else
Try
If mode = 1 Then
url = ("http://ws.spotify.com/search/1/track?q=" & (Songname))
ElseIf mode = 2 Then
url = ("http://ws.spotify.com/search/1/artist?q=" & (Songname))
ElseIf mode = 3 Then
url = ("http://ws.spotify.com/album/1/track?q=" & (Songname))
End If
MsgBox(url)
reader = XDocument.Load(url)
MsgBox("Done")
Catch ex As Exception
Return False
MsgBox(ex.ToString & (" DSAD"))
End Try
End If
For Each tracks As XElement In reader...<tracks>...<track>
Dim songnaaame As String = reader.Element("name")
MsgBox(songnaaame)
Next

End Function

Viewing all articles
Browse latest Browse all 27353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>