
$.ajax({
type: "GET",
url: "books.xml",
dataType: "xml",
success: function(xml) {
var xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc),
books = [];
$xml.find("book").each(function() {
var book = {
name: $(this).find("name").text(),
author: $(this).find("author").text(),
price: $(this).find("price").text()
};
books.push(book);
});
console.log(books);
}
});
上面是“如何将XML解析后的对象保存到JavaScript中”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4198.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

网站优化SEO双标题有什么用?
nginx如何限制网站来源ip访问