Tengo una duda, estoy tratando de obtener algunos datos de videos de youtube. Estos trato de sacarlos de su dirección en xml, por ejemplo: http://gdata.youtube.com/feeds/api/videos/adoSULz-SwM, la cual tiene la siguiente información:
Código HTML:
<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' 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/adoSULz-SwM</id><published>2012-02-24T15:50:39.000Z</published><updated>2012-02-27T18:14:10.000Z</updated><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='Games' label='Juegos'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='brutality'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='playstation'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='xbox 360'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='capcom'/><title type='text'>Resident Evil Operation Raccoon City Brutality Trailer</title><content type='text'>Check out some of the insanely brutal moves you can pull off. REORC comes out in North America March 23rd for PS3 and Xbox 360, May 18th on PC.</content><link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=adoSULz-SwM&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/adoSULz-SwM/responses'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/adoSULz-SwM/related'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=adoSULz-SwM'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/adoSULz-SwM'/><author><name>CapcomUnityVideos</name><uri>http://gdata.youtube.com/feeds/api/users/CapcomUnityVideos</uri></author><gd:comments><gd:feedLink rel='http://gdata.youtube.com/schemas/2007#comments' href='http://gdata.youtube.com/feeds/api/videos/adoSULz-SwM/comments' countHint='663'/></gd:comments><yt:hd/><media:group><media:category label='Juegos' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Games</media:category><media:content url='http://www.youtube.com/v/adoSULz-SwM?version=3&f=videos&app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='94' yt:format='5'/><media:content url='rtsp://v8.cache5.c.youtube.com/CiILENy73wIaGQkDS_68UBLaaRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='94' yt:format='1'/><media:content url='rtsp://v3.cache3.c.youtube.com/CiILENy73wIaGQkDS_68UBLaaRMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='94' yt:format='6'/><media:description type='plain'>Check out some of the insanely brutal moves you can pull off. REORC comes out in North America March 23rd for PS3 and Xbox 360, May 18th on PC.</media:description><media:keywords>brutality, playstation, xbox 360, capcom</media:keywords><media:player url='http://www.youtube.com/watch?v=adoSULz-SwM&feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/adoSULz-SwM/0.jpg' height='360' width='480' time='00:00:47'/><media:thumbnail url='http://i.ytimg.com/vi/adoSULz-SwM/1.jpg' height='90' width='120' time='00:00:23.500'/><media:thumbnail url='http://i.ytimg.com/vi/adoSULz-SwM/2.jpg' height='90' width='120' time='00:00:47'/><media:thumbnail url='http://i.ytimg.com/vi/adoSULz-SwM/3.jpg' height='90' width='120' time='00:01:10.500'/><media:title type='plain'>Resident Evil Operation Raccoon City Brutality Trailer</media:title><yt:duration seconds='94'/></media:group><gd:rating average='4.651438' max='5' min='1' numRaters='1182' rel='http://schemas.google.com/g/2005#overall'/><yt:statistics favoriteCount='238' viewCount='140401'/></entry>
Código:
Sin embargo, cuando trato de llamar los datos no me funciona. Al final necesito colocarlos en la siguiente etiqueta: $(document).ready(function() { $.ajax({ type: "GET", url: "http://gdata.youtube.com/feeds/api/videos/adoSULz-SwM", dataType: "xml", success: function (xml){ $(xml).find("title").each(function() { var title = $(this).find('title').text(); $('#titulo').text(title); alert(title); }); } }); });
Código HTML:
<h1 id="titulo">Sin título</h1>
De antemano, un saludo.