
$.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,我们会在看到邮件的第一时间内为您处理!

帝国CMS7.5版来源地址新增严格模式验证,更严谨
Cambly:拥有来自美国、英国、加拿大和澳大利亚等英语母语国家的25000多名外教
熊猫输入法
抖音冷知识:抖音大佬都不可能告诉你的“四个网站”
歌者AI:自动提取关键信息并生成对应的PPT文本、图表与配图