Foros del Web » Programando para Internet » ASP Clásico »

Leer XML de YOUTUBE con ASP

Estas en el tema de Leer XML de YOUTUBE con ASP en el foro de ASP Clásico en Foros del Web. Buenas :) Veréis, estoy haciendo una web donde la gente pondrá la URL de un vídeo de YouTube y quiero sacar el título del vídeo ...
  #1 (permalink)  
Antiguo 02/11/2010, 12:55
Avatar de franciscoooooouu  
Fecha de Ingreso: marzo-2010
Mensajes: 10
Antigüedad: 14 años
Puntos: 3
Pregunta Leer XML de YOUTUBE con ASP

Buenas :)

Veréis, estoy haciendo una web donde la gente pondrá la URL de un vídeo de YouTube y quiero sacar el título del vídeo desde el XML.
Tengo uno pero es indicando la posición del item y en cada vídeo cambia, lo que me gustaría es que lea el "<title>".

CÓDIGO ASP
Código HTML:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' Variables.
Dim xmlObj, v_item
Dim titulo
Dim Salto

'Asigno Variables.
Salto = Replace (cadena, vbCrLf, "<BR>")

'Creo el objeto de XMLDOM
Set xmlObj = Server.CreateObject("Microsoft.XMLDOM")
'No dejo que el archivo se edite si está en uso
xmlObj.async = False
xmlObj.setProperty "ServerHTTPRequest", true
xmlObj.validateOnParse = False
xmlObj.resolveExternals = False

'Cargo el archivo
xmlObj.load ("http://gdata.youtube.com/feeds/api/videos/" & Request.QueryString("Id"))

'Si el archivo XML tiene errores
If xmlObj.parseError.errorCode <> 0 Then 
Response.Write("Error de Lectura (Por favor, ponerse en contacto con el webmaster).<br />FilePos: " & xmlObj.parseError.filepos & "<br /> Línea: " & xmlObj.parseError.Line & "<br /> Causa: " & xmlObj.parseError.reason & "<br /> Ocurrió en: " & xmlObj.parseError.srcText & "<br /> Archivo: " & xmlObj.parseError.URL)
Response.End
'Si no contiene errores continuo.
Else
'Creo v_item y ejecuto la orden.
Set v_item = xmlObj.getElementsByTagName("entry")

''''''''''''' * * BUCLE * * ''''''''''''''
'Recorre todas las filas del resultado
For n=0 To v_item.length-1
titulo = xmlObj.selectSingleNode("/entry").childNodes(10).childNodes(0).Text '"title"
%><%
'''''''''''' * * BUCLE * * ''''''''End If
'Pasa a la siguiente fila
Next
'v_item.Close
Set v_item = Nothing
'xmlObj.Close
Set xmlObj = Nothing

End If
%>

XML DE YOUTUBE
Código HTML:
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:app='http://purl.org/atom/app#' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<id>http://gdata.youtube.com/feeds/api/videos/EVBsypHzF3U</id>
<published>2010-03-15T19:58:21.000Z</published>
<updated>2010-10-30T17:40:37.000Z</updated>
<app:control>
  <yt:state name='restricted' reasonCode='limitedSyndication'>Syndication of this video was restricted by its owner.</yt:state>
</app:control>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Music' label='Música'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Lady'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Gaga'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='SKI'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Pop'/>

<title type='text'>Lady Gaga - Telephone ft. Beyoncé</title>
<content type='text'>Music video by Lady Gaga performing Telephone (Clean Version). (C) 2010 Interscope Records</content>
<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=EVBsypHzF3U&amp;feature=youtube_gdata'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/EVBsypHzF3U/responses'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/EVBsypHzF3U/related'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/EVBsypHzF3U'/>
<author>
  <name>LadyGagaVEVO</name>
  <uri>http://gdata.youtube.com/feeds/api/users/ladygagavevo</uri>
</author>
<gd:comments>
  <gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/EVBsypHzF3U/comments' countHint='103121'/>
</gd:comments>
<media:group>
  <media:category label='Música' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Music</media:category>
  <media:content url='http://www.youtube.com/v/EVBsypHzF3U?f=videos&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='571' yt:format='5'/>
  <media:description type='plain'>Music video by Lady Gaga performing Telephone (Clean Version). (C) 2010 Interscope Records</media:description>
  <media:keywords>Lady, Gaga, SKI, Pop</media:keywords>
  <media:player url='http://www.youtube.com/watch?v=EVBsypHzF3U&amp;feature=youtube_gdata_player'/>
  <media:restriction type='country' relationship='deny'>DE</media:restriction>
  <media:thumbnail url='http://i.ytimg.com/vi/EVBsypHzF3U/2.jpg' height='90' width='120' time='00:04:45.500'/>
  <media:thumbnail url='http://i.ytimg.com/vi/EVBsypHzF3U/1.jpg' height='90' width='120' time='00:02:22.750'/>
  <media:thumbnail url='http://i.ytimg.com/vi/EVBsypHzF3U/3.jpg' height='90' width='120' time='00:07:08.250'/>
  <media:thumbnail url='http://i.ytimg.com/vi/EVBsypHzF3U/0.jpg' height='240' width='320' time='00:04:45.500'/>
  <media:title type='plain'>Lady Gaga - Telephone ft. Beyoncé</media:title>
  <yt:duration seconds='571'/>
</media:group>
<gd:rating average='4.4441013' max='5' min='1' numRaters='114690' rel='http://schemas.google.com/g/2005#overall'/>
<yt:statistics favoriteCount='160908' viewCount='89389215'/>

</entry> 
Espero haberme explicado bien, saludos

Etiquetas: asp, feed, rss, xml, youtube
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:45.