我一直在谷歌搜索解决方案几个小时,但没有发现任何针对我的具体问题。
我一直在试验这段代码:
$.ajax({
url: 'https://gdata.youtube.com/feeds/api/users/profinsights/uploads',
dataType: "xml",
success: parseXml
});
function parseXml(xml) {
var entrynode = xml.getElementsByTagName("entry");
$(entrynode).each(function() {
//console.log($(this));
console.log($('id',this)); //matches <id successfully
console.log($('media:group',this)); // no match
});
}
XML片段:
...
<entry>
<id>http://gdata.youtube.com/feeds/api/videos/870MupRJhmU</id>
<title type="text">PIMS Humble Beginnings</title>
<author>…</author>
<gd:comments>…</gd:comments>
<media:group>
<media:category label="Education" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Education</media:category>
<media:content url="https://www.youtube.com/v/870MupRJhmU?version=3&f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="561" yt:format="5"></media:content>
<media:content url="rtsp://v3.cache3.c.youtube.com/CigLENy73wIaHwllhkmUugy98xMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="561" yt:format="1"></media:content>
<media:content url="rtsp://v1.cache7.c.youtube.com/CigLENy73wIaHwllhkmUugy98xMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="561" yt:format="6"></media:content>
<media:description type="plain">…</media:description>
<media:keywords>…</media:keywords>
<media:player url="https://www.youtube.com/watch?v=870MupRJhmU&feature=youtube_gdata_player"></media:player>
<media:thumbnail url="http://i.ytimg.com/vi/870MupRJhmU/0.jpg" height="360" width="480" time="00:04:40.500"></media:thumbnail>
<media:thumbnail url="http://i.ytimg.com/vi/870MupRJhmU/1.jpg" height="90" width="120" time="00:02:20.250"></media:thumbnail>
<media:thumbnail url="http://i.ytimg.com/vi/870MupRJhmU/2.jpg" height="90" width="120" time="00:04:40.500"></media:thumbnail>
<media:thumbnail url="http://i.ytimg.com/vi/870MupRJhmU/3.jpg" height="90" width="120" time="00:07:00.750"></media:thumbnail>
<media:title type="plain">PIMS Humble Beginnings</media:title>
<yt:duration seconds="561"></yt:duration>
</media:group>
</entry>
...
<media:foo>
提前谢谢。
编辑:顺便说一句,这是上述代码的小提琴:http://jsfiddle.net/vYJwm/
更新:
问题已解决。谢谢你们。
答案 0 :(得分:0)