Javascript 使用jquery从xml获取数据
试试这个插件:Javascript 使用jquery从xml获取数据,javascript,jquery,xml,parsing,Javascript,Jquery,Xml,Parsing,试试这个插件: (“一个简单的jQuery插件,它将XML数据(通常从$.ajax请求转换为有效的JSON对象)。类似的东西可以用于解析的XML var slideShowContent = Array( Array('Kung Fu Panda', 'In the Valley of Peace, Po the Panda finds himself chosen as the Dragon Warrior despite', 'pages/images/slider/a.jpg'),
(“一个简单的jQuery插件,它将XML数据(通常从$.ajax请求转换为有效的JSON对象)。类似的东西可以用于解析的XML
var slideShowContent = Array(
Array('Kung Fu Panda', 'In the Valley of Peace, Po the Panda finds himself chosen as the Dragon Warrior despite', 'pages/images/slider/a.jpg'),
Array('Despicable Me', 'Gru is recruited by the Anti-Villain League to help deal with a powerful new super criminal.', 'pages/images/slider/b.jpg'),
Array('Craigslist Joe', "In a time when America's economy was crumbling and sense of community was in question", 'pages/images/slider/c.jpg'),
Array('X: Night of Vengeance', 'A jaded call-girl. A fledgling hooker. The night from hell.', 'pages/images/slider/d.jpg'),
Array('Rock of Ages', 'A small town girl and a city boy meet on the Sunset Strip, while pursuing their Hollywood dreams.', 'pages/images/slider/e.jpg'));
可能存在的副本
var slideShowContent = Array(
Array('Kung Fu Panda', 'In the Valley of Peace, Po the Panda finds himself chosen as the Dragon Warrior despite', 'pages/images/slider/a.jpg'),
Array('Despicable Me', 'Gru is recruited by the Anti-Villain League to help deal with a powerful new super criminal.', 'pages/images/slider/b.jpg'),
Array('Craigslist Joe', "In a time when America's economy was crumbling and sense of community was in question", 'pages/images/slider/c.jpg'),
Array('X: Night of Vengeance', 'A jaded call-girl. A fledgling hooker. The night from hell.', 'pages/images/slider/d.jpg'),
Array('Rock of Ages', 'A small town girl and a city boy meet on the Sunset Strip, while pursuing their Hollywood dreams.', 'pages/images/slider/e.jpg'));
var slideShowContent = $.map($(xml).find('slider').children(), function(node, i) {
return [[$('title', node).text(), $('content', node).text(), $('img', node).text()]];
});
var xml_data = '[xml_data_here]',
$slider = $( $.parseXML(xml_data) ).find('slider'),
slider_data = [];
$slider.children().each(function() {
var slide = [];
$(this).children().each(function() {
slide.push( $(this).text() );
});
slider_data.push( slide );
});