Loop not returning proper result
Hi there,
I'm trying to make a YouTube photo gallery, and it's all working apart from not returning the correct ID properly. For example, when the user clicks on an image link, they are taken to the full video. I think the problem is in the For Each loops but I can't see what it could be. Hope someone can point me in the right direction.
Code:
Set xmlList = xml.getElementsByTagName("entry")
Set nodeList = xml.SelectNodes("//media:thumbnail")
For Each xmlItem In xmlList
YouTubeID = xmlItem.getElementsByTagName("id")(0).Text
TrimmedID = Replace(YouTubeID, "http://gdata.youtube.com/feeds/api/videos/", "")
Title = xmlItem.getElementsByTagName("title")(0).Text
Next
For Each xmlItem2 In nodeList
thumbnailUrl = xmlItem2.getAttribute("url")
'Title = xmlItem2.getAttribute("title")
If Right(thumbnailUrl, 5) = "0.jpg" Then
Response.Write "<a href='http://www.youtube.com/watch?v=" & TrimmedID & " target='_blank'><img class='YouTube' src='" & thumbnailUrl & "' width='120' height='90' alt='' title='" & Title & "' /></a>"
End If
Next
Thanks
Douglas