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

如何去掉win10系统激活水印
Wiseflow:一款开源免费、轻量化敏捷的信息挖掘工具
知源中医APP
中华古籍智慧化服务平台:国家图书馆牵头,收录13,310种古籍
豆包大模型1.6-vision:支持Responses API,能自主调用工具如定位/剪裁/点选/画线等