xml和javascript问题 [英] xml and javascript question

查看:52
本文介绍了xml和javascript问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究从xml播放列表中提取的视频播放器.到目前为止,我已经完全成功地从以下xml结构中获取了成功:

课程章节-循环播放对象标题(视频标题)屏幕(视频位置和类型)说明(视频描述)/章节/课程

这是我想做的,但是很难理解如何正确设置它:

课程courseinfo label ="章节标签="屏幕标签="(代替标题)path ="(文件的URL)type ="video/mp4"/screen/章节/courseinfo/course

这是我正在使用的代码:

I''m working on a video player that pulls from an xml playlist. So far I have it success fully pulling from the following xml structure:

course chapter - looping object title (video title) screen (video location and type) description (description of video) /chapter /course

Here is what I would like to do, but am having difficulty understanding how to set it up properly:

course courseinfo label=" " chapter label =" " screen label = " " (instead of title) path= " " (url to file) type="video/mp4" /screen /chapter /courseinfo /course

here is the code that I am using:

 // properties
var XML_PATH = "xml/screens.xml"; var videos_array=new Array();

// init the application function init() { // call loadXML function loadXML(); }

// XML loading function loadXML() { $.ajax({ type: "GET", url: XML_PATH, dataType: "xml", success: function onXMLloaded(xml) {

// loop for each item $(xml).find('chapter').each(function loopingItems(value) { // create an object var obj={title:$(this).find("title").text(), screen:$(this).find("screen").text(),

description:$(this).find("description").text()}; videos_array.push(obj);

// append

and video title $("#playlist2").append('
'); $("#playlist2").append(''+obj.title+''); });
// close

$("#playlist2").append('
'); // append video tag player $("#player").append(' src="'+videos_array[0].screen+'" type="video/mp4" />Your browser does not support the 
video tag.'); // append description $("#description").append(videos_array[0].description);
// call addListeners function addListeners(); } }); }

// add

listener function addListeners() { // loop for each list item $('#playlist2 li').each(function looping(index) { // onclick... $(this).click(function onItemClick() { // empty playlist and description $("#player").empty(); $("#description").empty(); // append video tag $("#player").append(' src="'+videos_array[index].screen+'" type="video/mp4" />Your browser does not support 
the video tag.'); // append description $("#description").append(videos_array[index].description); }); }); }


另外,我想在名为#courseinfo的框中显示课程信息标签.播放器的顶部设置了视频元素,然后我一直试图在其下放置Courseinfo,然后是说明,然后是实际的播放列表.

任何帮助将不胜感激


Also, I want to display the course info lable in a box called #courseinfo. The player is set up with the video element on top, then I''ve been trying to put in the courseinfo under that, then the description, then the actual playlist.

any help would be much appreciated

推荐答案

.ajax({类型:"GET",url:XML_PATH,dataType:"xml",成功:函数onXMLloaded(xml) { 每个项目的// 循环
.ajax({ type: "GET", url: XML_PATH, dataType: "xml", success: function onXMLloaded(xml) { // loop for each item


(xml).find('章节' ).each(function loopingItems(value){//创建一个对象var obj = {title:
(xml).find('chapter').each(function loopingItems(value) { // create an object var obj={title:


(this).find("title").text(),屏幕:
(this).find("title").text(), screen:


这篇关于xml和javascript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆