Parse Youtube XML

typeman

New Member
I'm using a basic method to parse some Youtube XML data:This is a sample XML file from Youtube: http://jimpix.co.uk/youtube.xmlI saved it as XML as the XML file is a lot easier to see than the standard Youtube version from Youtube (see here)This is the basic code I'm using to extract the video ID and Title:\[code\]Dim vurl = "http://jimpix.co.uk/youtube.xml"Set http = Server.CreateObject("msxml2.ServerXMLHTTP")http.Open "GET", vurl, Falsehttp.SendSet dom = http.responseXMLSet items = dom.getElementsByTagName("entry")For Each item In itemsSet id = item.getElementsByTagName("name")If NOT (id IS Nothing) Then var_id = id(0).TextEnd Ifresponse.write "<hr>var_id: "&var_id&"</hr>"Set title = item.getElementsByTagName("title")If NOT (title IS Nothing) Then var_title = title(0).TextEnd Ifresponse.write "<hr>var_title: "&var_title&"</hr>" Next\[/code\]I'm stuck trying to get at the video duration, thumbnail and number of plays, as they are not held in simple tags like the ID and title.For example, ID and title go like this:\[code\]<entry...> <id>http://gdata.youtube.com/feeds/api/videos/9TN3VtWwks4</id> ... <title type="text"> Sign Language - Multi-Award Winning short film - Director's Cut </title></entry>\[/code\]But the duration, thumbnail and number of plays are harder to get at:\[code\]<entry...> <media:group> <media:thumbnail url="http://i.ytimg.com/vi/9TN3VtWwks4/0.jpg" height="360" width="480" time="00:02:28.500"/> <yt:duration seconds="297"/> <yt:statistics favoriteCount="0" viewCount="198826"/> </media:group></entry>\[/code\]I wondered if I could ask for advice please about how to extract these 3 variables from the XML?
 
Back
Top